Skip to content

Instantly share code, notes, and snippets.

@johnament
Created January 9, 2011 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnament/771790 to your computer and use it in GitHub Desktop.
Save johnament/771790 to your computer and use it in GitHub Desktop.
Should this work correctly with HornetQ?
@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());
}
}
@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