Search in sources :

Example 11 with Session

use of quickfix.Session in project camel by apache.

the class QuickfixjEventJsonTransformer method transform.

public String transform(Exchange exchange) {
    SessionID sessionID = exchange.getIn().getHeader(QuickfixjEndpoint.SESSION_ID_KEY, SessionID.class);
    Session session = Session.lookupSession(sessionID);
    DataDictionary dataDictionary = session.getDataDictionary();
    if (dataDictionary == null) {
        throw new IllegalStateException("No Data Dictionary. Exchange must reference an existing session");
    }
    StringBuilder sb = new StringBuilder();
    sb.append("\"event\": {\n");
    org.apache.camel.Message in = exchange.getIn();
    for (String key : in.getHeaders().keySet()) {
        sb.append("  \"").append(key).append("\": ").append(in.getHeader(key)).append(",\n");
    }
    sb.append(renderer.transform(in.getBody(Message.class), "  ", dataDictionary)).append("\n");
    sb.append("}\n");
    return sb.toString();
}
Also used : Message(quickfix.Message) DataDictionary(quickfix.DataDictionary) SessionID(quickfix.SessionID) Session(quickfix.Session)

Example 12 with Session

use of quickfix.Session in project camel by apache.

the class QuickfixjMessageJsonTransformer method transform.

public String transform(Message message) throws FieldNotFound, ConfigError {
    SessionID sessionID = MessageUtils.getSessionID(message);
    Session session = Session.lookupSession(sessionID);
    DataDictionary dataDictionary = session.getDataDictionary();
    if (dataDictionary == null) {
        throw new IllegalStateException("No Data Dictionary. Exchange must reference an existing session");
    }
    return transform(message, dataDictionary);
}
Also used : DataDictionary(quickfix.DataDictionary) SessionID(quickfix.SessionID) Session(quickfix.Session)

Aggregations

Session (quickfix.Session)12 Message (quickfix.Message)8 SessionID (quickfix.SessionID)7 Test (org.junit.Test)6 DataDictionary (quickfix.DataDictionary)4 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 Email (quickfix.fix42.Email)2 Message (org.apache.camel.Message)1 DataDictionaryProvider (quickfix.DataDictionaryProvider)1 SessionNotFound (quickfix.SessionNotFound)1 ApplVerID (quickfix.field.ApplVerID)1