Skip to content

Instantly share code, notes, and snippets.

Created July 13, 2012 06:42
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
SwitchYard Completion Event Notifier
config = SwitchYardTestCaseConfig.SWITCHYARD_XML,
mixins = {CDIMixIn.class, HornetQMixIn.class},
scanners = BeanSwitchYardScanner.class)
public class CamelJMSBindingTest {
private static final String QUEUE_NAME = "GreetingServiceQueue";
private SwitchYardTestKit _testKit;
public void sendTextMessageToJMSQueue() throws Exception {
final String payload = "dummy payload";
final CompletionNotifier<String> notifier = new CompletionNotifier<String>(String.class);
_testKit.getServiceDomain().addEventObserver(notifier, ExchangeCompletionEvent.class);
sendTextToQueue(payload, QUEUE_NAME);
// Allow for the JMS Message to be processed.
final String recievedMessage = notifier.getMessage();
assertThat(recievedMessage, equalTo("Greeted " + payload));
private class CompletionNotifier<T> implements EventObserver {
private T _processed;
private Class<T> _type;
public CompletionNotifier(final Class<T> type) {
_type = type;
public void notify(final EventObject event) {
final Exchange ex = (Exchange) event.getSource();
_processed = ex.getMessage().getContent(_type);
public T getMessage() {
return _processed;
public class GreetingServiceBean
implements org.switchyard.quickstarts.camel.jms.binding.GreetingService {
public final String greet(final String name) {
System.out.println("Hello there " + name + " :-) ");
return "Greeted " + name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment