use of quickfix.field.MsgSeqNum 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);
}
}
use of quickfix.field.MsgSeqNum 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));
}
use of quickfix.field.MsgSeqNum 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);
}
}
use of quickfix.field.MsgSeqNum in project wso2-synapse by wso2.
the class FIXTransportSenderTest method testFIXTransportSenderSendMessage.
@Test()
public void testFIXTransportSenderSendMessage() throws Exception {
String BEGIN_STRING = "FIX.4.1";
String SENDER_ID = "BANZAI";
String TARGET_ID = "SYNAPSE";
int SEQ_NUM = 5;
String SYMBOL = "APACHE";
String CLORD_ID = "12345";
String CHECKSUM = "67890";
String TX_DATE = new Date().toString();
String SESSION_ID = "FIX.4.1:BANZAI->SYNAPSE";
Message message = new NewOrderSingle();
message.getHeader().setField(new BeginString(BEGIN_STRING));
message.getHeader().setField(new SenderCompID(SENDER_ID));
message.getHeader().setField(new TargetCompID(TARGET_ID));
message.getHeader().setField(new MsgSeqNum(SEQ_NUM));
message.setField(new Symbol(SYMBOL));
message.setField(new ClOrdID(CLORD_ID));
message.setField(new TradeOriginationDate(TX_DATE));
message.getTrailer().setField(new CheckSum(CHECKSUM));
MessageContext msgCtx = new MessageContext();
msgCtx.setProperty(FIXConstants.FIX_SERVICE_NAME, "sampleService");
Map trpHeaders = new HashMap();
trpHeaders.put(FIXConstants.FIX_MESSAGE_APPLICATION, "sampleApplication");
msgCtx.setProperty(MessageContext.TRANSPORT_HEADERS, trpHeaders);
FIXUtils.getInstance().setSOAPEnvelope(message, SEQ_NUM, SESSION_ID, msgCtx);
OutTransportInfo info = new FIXOutTransportInfo("fix://dummyEPR");
FIXTransportSender spy = PowerMockito.spy(new FIXTransportSender());
PowerMockito.doReturn(true).when(spy, "sendUsingEPR", anyString(), anyString(), any(), anyString(), anyInt(), any());
spy.sendMessage(msgCtx, "fix://dummyEPR", info);
PowerMockito.verifyPrivate(spy, times(1)).invoke("sendUsingEPR", anyString(), anyString(), any(), anyString(), anyInt(), any());
}
use of quickfix.field.MsgSeqNum in project wso2-synapse by wso2.
the class FIXIncomingMessageHandlerTest method testFromAdmin.
@Test
public void testFromAdmin() throws Exception {
SessionID id = new SessionID(new BeginString("FIX.4.1"), new SenderCompID("SYNAPSE"), new TargetCompID("BANZAI"), "FIX.4.1:SYNAPSE->BANZAI");
Message message = new NewOrderSingle();
message.getHeader().setField(new BeginString("FIX.4.1"));
message.getHeader().setField(new SenderCompID("SYNAPSE"));
message.getHeader().setField(new TargetCompID("BANZAI"));
message.getHeader().setField(new MsgSeqNum(1));
message.getHeader().setField(new MsgType("A"));
ConfigurationContext cfgCtx = new ConfigurationContext(new AxisConfiguration());
WorkerPool pool = new NativeWorkerPool(3, 4, 10, 10, "name", "id");
FIXIncomingMessageHandler handler = new FIXIncomingMessageHandler(cfgCtx, pool, service, true);
handler.fromAdmin(message, id);
}
Aggregations