Skip to content

Instantly share code, notes, and snippets.

@patelm5
Created January 14, 2013 17:27
Show Gist options
  • Save patelm5/4531699 to your computer and use it in GitHub Desktop.
Save patelm5/4531699 to your computer and use it in GitHub Desktop.
Broadcast Listener for rabbitmq
@Component("broadcastQueueConsumer")
public class BroadcastListener implements MessageListener{
private final static Logger logger = Logger.getLogger(BroadcastListener.class.getName());
@Autowired
private SimpleMessageConverter messageAdapter ;
@Autowired
private BroadcastService broadcastService;
@Override
public void onMessage(Message message) {
try {
String convertedMessage = (String) messageAdapter.fromMessage(message);
broadcastService.broadcast(convertedMessage);
} catch (Exception e) {
logger.warning("Unable to read message (err: "+e+")");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment