Search in sources :

Example 6 with MsgType

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

the class FIXIncomingMessageHandler method toAdmin.

/**
 * This callback provides Synapse with a peek at the administrative messages
 * that are being sent from your FIX engine to the counter party. This is
 * normally not useful for an application however it is provided for any
 * logging one may wish to do.
 *
 * @param message   QuickFIX message
 * @param sessionID QuickFIX session ID
 */
public void toAdmin(Message message, SessionID sessionID) {
    if (log.isDebugEnabled()) {
        StringBuffer sb = new StringBuffer();
        try {
            sb.append("Sending admin 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 admin 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());
        }
    }
    try {
        // Before FIX server sends (35=A) admin login message get username/password values from proxy configuration
        if (message.getHeader().getField(new StringField(FIXConstants.FIX_MESSAGE_TYPE)).getValue().equals(FIXConstants.LOGON)) {
            Parameter userName = service.getParameter(FIXConstants.FIX_USERNAME);
            Parameter passWord = service.getParameter(FIXConstants.FIX_PASSWORD);
            if (userName != null && passWord != null) {
                message.setString(FIXConstants.USERNAME_TAG, userName.getValue().toString());
                message.setString(FIXConstants.PASSWORD_TAG, passWord.getValue().toString());
            }
            if (log.isDebugEnabled()) {
                log.debug("Username:" + userName + " or password:" + passWord + "from proxy configuration..");
            }
        }
    } catch (FieldNotFound e) {
        log.error("One or more required fields are not found in the response message", e);
    }
    if (eventHandler != null) {
        eventHandler.toAdmin(this, message, sessionID);
    }
}
Also used : SenderCompID(quickfix.field.SenderCompID) TargetCompID(quickfix.field.TargetCompID) Parameter(org.apache.axis2.description.Parameter) MsgType(quickfix.field.MsgType) MsgSeqNum(quickfix.field.MsgSeqNum)

Aggregations

MsgSeqNum (quickfix.field.MsgSeqNum)6 MsgType (quickfix.field.MsgType)6 SenderCompID (quickfix.field.SenderCompID)6 TargetCompID (quickfix.field.TargetCompID)6 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 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 Message (quickfix.Message)3 SessionID (quickfix.SessionID)3 BeginString (quickfix.field.BeginString)3 NewOrderSingle (quickfix.fix41.NewOrderSingle)3 Parameter (org.apache.axis2.description.Parameter)2