Search in sources :

Example 1 with SenderCompID

use of quickfix.field.SenderCompID in project wso2-synapse by wso2.

the class FIXIncomingMessageHandler method toApp.

/**
 * This is a callback for application messages that are being sent to a
 * counter party.
 *
 * @param message   QuickFIX message
 * @param sessionID QuickFIX session ID
 * @throws DoNotSend This exception aborts message transmission
 */
public void toApp(Message message, SessionID sessionID) throws DoNotSend {
    if (log.isDebugEnabled()) {
        StringBuffer sb = new StringBuffer();
        try {
            sb.append("Sending application level FIX message to ").append(message.getHeader().getField(new TargetCompID()).getValue());
            sb.append("\nMessage Type: ").append(message.getHeader().getField(new MsgType()).getValue());
            sb.append("\nMessage Sequence Number: ").append(message.getHeader().getField(new MsgSeqNum()).getValue());
            sb.append("\nSender ID: ").append(message.getHeader().getField(new SenderCompID()).getValue());
        } catch (FieldNotFound e) {
            sb.append("Sending application level FIX message...");
            log.warn("One or more required fields are not found in the response message", e);
        }
        log.debug(sb.toString());
        if (log.isTraceEnabled()) {
            log.trace("Message: " + message.toString());
        }
    }
    if (eventHandler != null) {
        eventHandler.toApp(this, message, sessionID);
    }
}
Also used : SenderCompID(quickfix.field.SenderCompID) TargetCompID(quickfix.field.TargetCompID) MsgType(quickfix.field.MsgType) MsgSeqNum(quickfix.field.MsgSeqNum)

Example 2 with SenderCompID

use of quickfix.field.SenderCompID in project wso2-synapse by wso2.

the class FIXIncomingMessageHandler method fromApp.

/**
 * This callback receives messages for the application. This is one of the
 * core entry points for the FIX application. Every application level
 * request will come through here. A new thread will be spawned from the
 * thread pool for each incoming message.
 *
 * @param message   QuickFIX message
 * @param sessionID QuickFIX session ID
 * @throws FieldNotFound
 * @throws IncorrectDataFormat
 * @throws IncorrectTagValue
 * @throws UnsupportedMessageType
 */
public void fromApp(Message message, SessionID sessionID) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType {
    if (log.isDebugEnabled()) {
        StringBuffer sb = new StringBuffer();
        sb.append("Received FIX message from ").append(message.getHeader().getField(new SenderCompID()).getValue());
        sb.append("\nMessage Sequence Number: ").append(message.getHeader().getField(new MsgSeqNum()).getValue());
        sb.append("\nReceiver ID: ").append(message.getHeader().getField(new TargetCompID()).getValue());
        log.debug(sb.toString());
        if (log.isTraceEnabled()) {
            log.trace("Message: " + message.toString());
        }
    }
    AtomicInteger atomicCounter = countersMap.get(sessionID);
    int counter = atomicCounter.incrementAndGet();
    boolean rolled = atomicCounter.compareAndSet(FIXConstants.DEFAULT_COUNTER_UPPER_LIMIT, 0);
    if (rolled && log.isDebugEnabled()) {
        log.debug("Incoming request counter rolled over for the session: " + sessionID);
    }
    workerPool.execute(new FIXWorkerThread(message, sessionID, counter));
}
Also used : SenderCompID(quickfix.field.SenderCompID) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TargetCompID(quickfix.field.TargetCompID) MsgSeqNum(quickfix.field.MsgSeqNum)

Example 3 with SenderCompID

use of quickfix.field.SenderCompID in project wso2-synapse by wso2.

the class FIXIncomingMessageHandler method fromAdmin.

/**
 * This callback notifies when an administrative message is sent from a
 * counterparty to the FIX engine.
 *
 * @param message   QuickFIX message
 * @param sessionID QuickFIX session ID
 * @throws FieldNotFound
 * @throws IncorrectDataFormat
 * @throws IncorrectTagValue
 * @throws RejectLogon         causes a logon reject
 */
public void fromAdmin(Message message, SessionID sessionID) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon {
    if (log.isDebugEnabled()) {
        StringBuffer sb = new StringBuffer();
        sb.append("Received admin level FIX message from ").append(message.getHeader().getField(new SenderCompID()).getValue());
        sb.append("\nMessage Type: ").append(message.getHeader().getField(new MsgType()).getValue());
        sb.append("\nMessage Sequence Number: ").append(message.getHeader().getField(new MsgSeqNum()).getValue());
        sb.append("\nReceiver ID: ").append(message.getHeader().getField(new TargetCompID()).getValue());
        log.debug(sb.toString());
        if (log.isTraceEnabled()) {
            log.trace("Message: " + message.toString());
        }
    }
    if (eventHandler != null) {
        eventHandler.fromAdmin(this, message, sessionID);
    }
}
Also used : SenderCompID(quickfix.field.SenderCompID) TargetCompID(quickfix.field.TargetCompID) MsgType(quickfix.field.MsgType) MsgSeqNum(quickfix.field.MsgSeqNum)

Example 4 with SenderCompID

use of quickfix.field.SenderCompID in project wso2-synapse by wso2.

the class FIXOutgoingMessageHandlerTest method testSendMessage.

@Test
public void testSendMessage() throws Exception {
    int SEQ_NUM = 1;
    String SESSION_ID = "FIX.4.1:BANZAI->SYNAPSE";
    Message message = new NewOrderSingle();
    MessageContext msgCtx = new MessageContext();
    PowerMockito.when(sessionFactory.getApplication(anyString())).thenReturn(app);
    PowerMockito.mockStatic(Session.class);
    PowerMockito.when(Session.sendToTarget(any(Message.class), any(SessionID.class))).thenReturn(true);
    SessionID id = new SessionID(new BeginString("FIX.4.1"), new SenderCompID("SYNAPSE"), new TargetCompID("BANZAI"), "FIX.4.1:SYNAPSE->BANZAI");
    spy.sendMessage(message, id, SESSION_ID, SEQ_NUM, msgCtx, "fix://sample");
    PowerMockito.verifyStatic(times(1));
}
Also used : NewOrderSingle(quickfix.fix41.NewOrderSingle) BeginString(quickfix.field.BeginString) SenderCompID(quickfix.field.SenderCompID) Message(quickfix.Message) TargetCompID(quickfix.field.TargetCompID) BeginString(quickfix.field.BeginString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) MessageContext(org.apache.axis2.context.MessageContext) SessionID(quickfix.SessionID) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with SenderCompID

use of quickfix.field.SenderCompID in project wso2-synapse by wso2.

the class FIXTransportSenderTest method testIsTargetValid.

@Test
public void testIsTargetValid() throws Exception {
    Map<String, String> fieldValues = new HashMap<>();
    fieldValues.put(FIXConstants.BEGIN_STRING, "FIX.4.1");
    fieldValues.put(FIXConstants.DELIVER_TO_COMP_ID, "SYNAPSE");
    fieldValues.put(FIXConstants.DELIVER_TO_SUB_ID, "sy");
    fieldValues.put(FIXConstants.DELIVER_TO_LOCATION_ID, "randomLoc");
    SessionID id = new SessionID(new BeginString("FIX.4.1"), new SenderCompID("BANZAI"), new SenderSubID("ba"), new SenderLocationID("senderLoc"), new TargetCompID("SYNAPSE"), new TargetSubID("sy"), new TargetLocationID("randomLoc"), "FIX.4.1:SYNAPSE->BANZAI");
    FIXTransportSender sender = new FIXTransportSender();
    Class senderClass = sender.getClass();
    Method isTargetvalid = senderClass.getDeclaredMethod("isTargetValid", Map.class, SessionID.class, boolean.class);
    isTargetvalid.setAccessible(true);
    Object result = isTargetvalid.invoke(senderClass.newInstance(), fieldValues, id, true);
    Assert.assertEquals("Invalid target!", "true", result.toString());
}
Also used : BeginString(quickfix.field.BeginString) SenderCompID(quickfix.field.SenderCompID) SenderSubID(quickfix.field.SenderSubID) HashMap(java.util.HashMap) TargetCompID(quickfix.field.TargetCompID) TargetSubID(quickfix.field.TargetSubID) TargetLocationID(quickfix.field.TargetLocationID) BeginString(quickfix.field.BeginString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Method(java.lang.reflect.Method) SenderLocationID(quickfix.field.SenderLocationID) SessionID(quickfix.SessionID) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

SenderCompID (quickfix.field.SenderCompID)10 TargetCompID (quickfix.field.TargetCompID)10 MsgSeqNum (quickfix.field.MsgSeqNum)8 Test (org.junit.Test)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 BeginString (quickfix.field.BeginString)6 MsgType (quickfix.field.MsgType)6 Message (quickfix.Message)5 SessionID (quickfix.SessionID)5 NewOrderSingle (quickfix.fix41.NewOrderSingle)5 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)3 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)3 NativeWorkerPool (org.apache.axis2.transport.base.threads.NativeWorkerPool)3 WorkerPool (org.apache.axis2.transport.base.threads.WorkerPool)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 HashMap (java.util.HashMap)2 MessageContext (org.apache.axis2.context.MessageContext)2 Parameter (org.apache.axis2.description.Parameter)2 Method (java.lang.reflect.Method)1 Date (java.util.Date)1