Created
January 9, 2011 16:25
-
-
Save johnament/771790 to your computer and use it in GitHub Desktop.
Should this work correctly with HornetQ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ApplicationScoped | |
@SomeQualifier | |
public class CDIMessageListener implements MessageListener { | |
@Inject Logger logger; | |
public void onMessage(Message m) { | |
logger.info("Received a message of type "+m.getClass().getCanonicalName()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Singleton @Startup | |
public class MessageMapper { | |
@Inject CDIMessageListener msgListener; | |
@Resource ConnectionFactory connectionFactory; | |
@Resource Topic topic; | |
@PostConstruct | |
public void init() { | |
Connection conn = connectionFactory.createConnection(); | |
Session session = conn.createSession(false,Session.AUTO_ACKNOWLEDGE); | |
MessageConsumer consumer = session.createConsumer(topic); | |
consumer.setMessageListener(msgListener); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment