Search in sources :

Example 16 with Message

use of quickfix.Message in project camel by apache.

the class QuickfixjEngineTest method doLogoffEventsTest.

private void doLogoffEventsTest(SessionID acceptorSessionID, SessionID initiatorSessionID, QuickfixjEngine quickfixjEngine) throws Exception {
    final List<EventRecord> events = new ArrayList<EventRecord>();
    final CountDownLatch logoffLatch = new CountDownLatch(2);
    QuickfixjEventListener logoffListener = new QuickfixjEventListener() {

        @Override
        public synchronized void onEvent(QuickfixjEventCategory eventCategory, SessionID sessionID, Message message) {
            EventRecord event = new EventRecord(eventCategory, sessionID, message);
            events.add(event);
            if (eventCategory == QuickfixjEventCategory.SessionLogoff) {
                logoffLatch.countDown();
            }
        }
    };
    quickfixjEngine.addEventListener(logoffListener);
    quickfixjEngine.stop();
    assertTrue("Logoffs not received", logoffLatch.await(5000, TimeUnit.MILLISECONDS));
    quickfixjEngine.removeEventListener(logoffListener);
    assertThat(events.size(), is(2));
    assertTrue(events.contains(new EventRecord(QuickfixjEventCategory.SessionLogoff, acceptorSessionID, null)));
    assertTrue(events.contains(new EventRecord(QuickfixjEventCategory.SessionLogoff, initiatorSessionID, null)));
}
Also used : Message(quickfix.Message) ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch) SessionID(quickfix.SessionID)

Example 17 with Message

use of quickfix.Message in project camel by apache.

the class FixMessageRouter method route.

public String route(Exchange exchange) {
    Message message = exchange.getIn().getBody(Message.class);
    if (message != null) {
        SessionID destinationSession = getDestinationSessionID(message);
        if (destinationSession != null) {
            String destinationUri = String.format("%s?sessionID=%s", engineUri, destinationSession);
            LOG.debug("Routing destination: {}", destinationUri);
            return destinationUri;
        }
    }
    return null;
}
Also used : Message(quickfix.Message) BeginString(quickfix.field.BeginString) SessionID(quickfix.SessionID)

Aggregations

Message (quickfix.Message)17 SessionID (quickfix.SessionID)12 Test (org.junit.Test)8 Exchange (org.apache.camel.Exchange)7 DefaultExchange (org.apache.camel.impl.DefaultExchange)4 Session (quickfix.Session)4 ArrayList (java.util.ArrayList)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 Before (org.junit.Before)3 Email (quickfix.fix42.Email)3 NoHops (quickfix.fix44.Message.Header.NoHops)3 IOException (java.io.IOException)2 Timer (java.util.Timer)2 TimerTask (java.util.TimerTask)2 JMException (javax.management.JMException)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 DataDictionary (quickfix.DataDictionary)2 Converter (org.apache.camel.Converter)1 Processor (org.apache.camel.Processor)1 InvalidMessage (quickfix.InvalidMessage)1