Created
January 14, 2013 17:27
-
-
Save patelm5/4531699 to your computer and use it in GitHub Desktop.
Broadcast Listener for rabbitmq
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
@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