当前位置: 首页>>代码示例>>Java>>正文


Java MsgType类代码示例

本文整理汇总了Java中quickfix.field.MsgType的典型用法代码示例。如果您正苦于以下问题:Java MsgType类的具体用法?Java MsgType怎么用?Java MsgType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MsgType类属于quickfix.field包,在下文中一共展示了MsgType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transform

import quickfix.field.MsgType; //导入依赖的package包/类
public void transform(Exchange exchange) throws FieldNotFound {
    // For the reply take the reverse sessionID into the account, see org.apache.camel.component.quickfixj.MessagePredicate
    String requestSessionID = exchange.getIn().getHeader("sessionID", String.class);
    String replySessionID = "FIX.4.2:MARKET->TRADER";
    LOG.info("Given the requestSessionID '{}' calculated the replySessionID as '{}'", requestSessionID, replySessionID);

    String orderID = exchange.getIn().getHeader("orderID", String.class);

    OrderStatusRequest request = new OrderStatusRequest(new ClOrdID("XYZ"), new Symbol("GOOG"), new Side(Side.BUY));
    request.set(new OrderID(orderID));
     
    // Look for a reply execution report back to the requester session
    // and having the requested OrderID. This is a loose correlation but the best
    // we can do with FIX 4.2. Newer versions of FIX have an optional explicit correlation field.
    exchange.setProperty(QuickfixjProducer.CORRELATION_CRITERIA_KEY, new MessagePredicate(
        new SessionID(replySessionID), MsgType.EXECUTION_REPORT).withField(OrderID.FIELD, request.getString(OrderID.FIELD)));
    
    exchange.getIn().setBody(request);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:RequestReplyExample.java

示例2: toExchange

import quickfix.field.MsgType; //导入依赖的package包/类
public static Exchange toExchange(Endpoint endpoint, SessionID sessionID, Message message, QuickfixjEventCategory eventCategory, ExchangePattern exchangePattern) {
    Exchange exchange = endpoint.createExchange(exchangePattern);

    org.apache.camel.Message camelMessage = exchange.getIn();
    camelMessage.setHeader(EVENT_CATEGORY_KEY, eventCategory);
    camelMessage.setHeader(SESSION_ID_KEY, sessionID);

    if (message != null) {
        try {
            camelMessage.setHeader(MESSAGE_TYPE_KEY, message.getHeader().getString(MsgType.FIELD));
        } catch (FieldNotFound e) {
            LOG.warn("Message type field not found in QFJ message: {}, continuing...", message);
        }
    }
    camelMessage.setBody(message);

    return exchange;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:QuickfixjConverters.java

示例3: convertToExchange

import quickfix.field.MsgType; //导入依赖的package包/类
@Test
public void convertToExchange() {
    SessionID sessionID = new SessionID("FIX.4.0", "FOO", "BAR");
    QuickfixjEndpoint endpoint = new QuickfixjEndpoint(null, "", new QuickfixjComponent());
    
    Message message = new Message();     
    message.getHeader().setString(MsgType.FIELD, MsgType.ORDER_SINGLE);
    
    Exchange exchange = QuickfixjConverters.toExchange(endpoint, sessionID, message, QuickfixjEventCategory.AppMessageSent);
    
    assertThat((SessionID)exchange.getIn().getHeader(QuickfixjEndpoint.SESSION_ID_KEY), is(sessionID));
    
    assertThat((QuickfixjEventCategory)exchange.getIn().getHeader(QuickfixjEndpoint.EVENT_CATEGORY_KEY), 
            is(QuickfixjEventCategory.AppMessageSent));
    
    assertThat((String)exchange.getIn().getHeader(QuickfixjEndpoint.MESSAGE_TYPE_KEY), is(MsgType.ORDER_SINGLE));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:QuickfixjConvertersTest.java

示例4: generateSequenceReset

import quickfix.field.MsgType; //导入依赖的package包/类
/**
 *
 * @param receivedMessage if not null, it is the message received and upon which the resend request is generated
 * @param beginSeqNo
 * @param endSeqNo
 * @throws FieldNotFound
 */
private void generateSequenceReset(Message receivedMessage, int beginSeqNo, int endSeqNo)
        throws FieldNotFound {
    final Message sequenceReset = messageFactory.create(sessionID.getBeginString(),
            MsgType.SEQUENCE_RESET);
    final int newSeqNo = endSeqNo;
    final Header header = sequenceReset.getHeader();
    header.setBoolean(PossDupFlag.FIELD, true);
    initializeHeader(header);
    header.setUtcTimeStamp(OrigSendingTime.FIELD, header.getUtcTimeStamp(SendingTime.FIELD));
    header.setInt(MsgSeqNum.FIELD, beginSeqNo);
    sequenceReset.setInt(NewSeqNo.FIELD, newSeqNo);
    sequenceReset.setBoolean(GapFillFlag.FIELD, true);
    if (receivedMessage != null && enableLastMsgSeqNumProcessed) {
        try {
            sequenceReset.getHeader().setInt(LastMsgSeqNumProcessed.FIELD,
                    receivedMessage.getHeader().getInt(MsgSeqNum.FIELD));
        } catch (final FieldNotFound e) {
            //should not happen as MsgSeqNum must be present
            getLog().onErrorEvent("Received message without MsgSeqNum " + receivedMessage);
        }
    }
    sendViaFixFilter(sequenceReset, beginSeqNo);
    getLog().onEvent("Sent SequenceReset TO: " + newSeqNo);
}
 
开发者ID:fix-protocol-tools,项目名称:STAFF,代码行数:32,代码来源:Session.java

示例5: generateLogout

import quickfix.field.MsgType; //导入依赖的package包/类
/**
 * To generate a logout message
 * @param otherLogout if not null, the logout message that is causing a logout to be sent
 * @param text
 */
private void generateLogout(Message otherLogout, String text) {
    final Message logout = messageFactory.create(sessionID.getBeginString(), MsgType.LOGOUT);
    initializeHeader(logout.getHeader());
    if (text != null && !"".equals(text)) {
        logout.setString(Text.FIELD, text);
    }
    if (otherLogout != null && enableLastMsgSeqNumProcessed) {
        try {
            logout.getHeader().setInt(LastMsgSeqNumProcessed.FIELD,
                    otherLogout.getHeader().getInt(MsgSeqNum.FIELD));
        } catch (final FieldNotFound e) {
            //should not happen as MsgSeqNum must be present
            getLog().onErrorEvent("Received logout without MsgSeqNum");
        }
    }
    sendViaFixFilter(logout, 0);
    state.setLogoutSent(true);
}
 
开发者ID:fix-protocol-tools,项目名称:STAFF,代码行数:24,代码来源:Session.java

示例6: generateReject

import quickfix.field.MsgType; //导入依赖的package包/类
private void generateReject(Message message, String str) throws FieldNotFound, IOException {
    final String beginString = sessionID.getBeginString();
    final Message reject = messageFactory.create(beginString, MsgType.REJECT);
    final Header header = message.getHeader();

    reject.reverseRoute(header);
    initializeHeader(reject.getHeader());

    final String msgType = header.getString(MsgType.FIELD);
    final String msgSeqNum = header.getString(MsgSeqNum.FIELD);
    if (beginString.compareTo(FixVersions.BEGINSTRING_FIX42) >= 0) {
        reject.setString(RefMsgType.FIELD, msgType);
    }
    reject.setString(RefSeqNum.FIELD, msgSeqNum);

    if (!msgType.equals(MsgType.LOGON) && !msgType.equals(MsgType.SEQUENCE_RESET)
            && !isPossibleDuplicate(message)) {
        state.incrNextTargetMsgSeqNum();
    }

    reject.setString(Text.FIELD, str);
    sendViaFixFilter(reject, 0);
    getLog().onErrorEvent("Reject sent for Message " + msgSeqNum + ": " + str);

}
 
开发者ID:fix-protocol-tools,项目名称:STAFF,代码行数:26,代码来源:Session.java

示例7: setRejectReason

import quickfix.field.MsgType; //导入依赖的package包/类
private void setRejectReason(Message reject, int field, String reason,
        boolean includeFieldInReason) {
    boolean isRejectMessage;
    try {
        isRejectMessage = MsgType.REJECT.equals(reject.getHeader().getString(MsgType.FIELD));
    } catch (final FieldNotFound e) {
        isRejectMessage = false;
    }
    if (isRejectMessage
            && sessionID.getBeginString().compareTo(FixVersions.BEGINSTRING_FIX42) >= 0) {
        reject.setInt(RefTagID.FIELD, field);
        reject.setString(Text.FIELD, reason);
    } else {
        reject.setString(Text.FIELD, reason + (includeFieldInReason ? " (" + field + ")" : ""));
    }
}
 
开发者ID:fix-protocol-tools,项目名称:STAFF,代码行数:17,代码来源:Session.java

示例8: generateBusinessReject

import quickfix.field.MsgType; //导入依赖的package包/类
private void generateBusinessReject(Message message, int err, int field) throws FieldNotFound,
        IOException {
    final Message reject = messageFactory.create(sessionID.getBeginString(),
            MsgType.BUSINESS_MESSAGE_REJECT);
    initializeHeader(reject.getHeader());
    final String msgType = message.getHeader().getString(MsgType.FIELD);
    final String msgSeqNum = message.getHeader().getString(MsgSeqNum.FIELD);
    reject.setString(RefMsgType.FIELD, msgType);
    reject.setString(RefSeqNum.FIELD, msgSeqNum);
    reject.setInt(BusinessRejectReason.FIELD, err);
    state.incrNextTargetMsgSeqNum();

    final String reason = BusinessRejectReasonText.getMessage(err);
    setRejectReason(reject, field, reason, field != 0);
    getLog().onErrorEvent(
            "Reject sent for Message " + msgSeqNum + (reason != null ? (": " + reason) : "")
                    + (field != 0 ? (": tag=" + field) : ""));

    sendViaFixFilter(reject, 0);
}
 
开发者ID:fix-protocol-tools,项目名称:STAFF,代码行数:21,代码来源:Session.java

示例9: validLogonState

import quickfix.field.MsgType; //导入依赖的package包/类
private synchronized boolean validLogonState(String msgType) {
    if (msgType.equals(MsgType.LOGON) && state.isResetSent() || state.isResetReceived()) {
        return true;
    }
    if (msgType.equals(MsgType.LOGON) && !state.isLogonReceived()
            || !msgType.equals(MsgType.LOGON) && state.isLogonReceived()) {
        return true;
    }
    if (msgType.equals(MsgType.LOGOUT) && state.isLogonSent()) {
        return true;
    }
    if (!msgType.equals(MsgType.LOGOUT) && state.isLogoutSent()) {
        return true;
    }
    if (msgType.equals(MsgType.SEQUENCE_RESET)) {
        return true;
    }
    if (msgType.equals(MsgType.REJECT)) {
        return true;
    }
    return false;
}
 
开发者ID:fix-protocol-tools,项目名称:STAFF,代码行数:23,代码来源:Session.java

示例10: nextQueued

import quickfix.field.MsgType; //导入依赖的package包/类
private boolean nextQueued(int num) throws FieldNotFound, RejectLogon, IncorrectDataFormat,
        IncorrectTagValue, UnsupportedMessageType, IOException, InvalidMessage {
    final Message msg = state.dequeue(num);

    if (msg != null) {
        getLog().onEvent("Processing queued message: " + num);

        final String msgType = msg.getHeader().getString(MsgType.FIELD);
        if (msgType.equals(MsgType.LOGON) || msgType.equals(MsgType.RESEND_REQUEST)) {
            state.incrNextTargetMsgSeqNum();
        } else {
            // TODO SESSION Is it really necessary to convert the queued message to a string?
            next(msg.toString());
        }
        return true;
    }
    return false;
}
 
开发者ID:fix-protocol-tools,项目名称:STAFF,代码行数:19,代码来源:Session.java

示例11: next

import quickfix.field.MsgType; //导入依赖的package包/类
private void next(String msg) throws InvalidMessage, FieldNotFound, RejectLogon,
        IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType, IOException {
    try {
        next(parseMessage(msg));
    } catch (final InvalidMessage e) {
        final String message = "Invalid message: " + e;
        if (MsgType.LOGON.equals(MessageUtils.getMessageType(msg))) {
            disconnect(message, true);
        } else {
            getLog().onErrorEvent(message);
            if (resetOrDisconnectIfRequired(null)) {
                return;
            }
        }
        throw e;
    }
}
 
开发者ID:fix-protocol-tools,项目名称:STAFF,代码行数:18,代码来源:Session.java

示例12: generateLogon

import quickfix.field.MsgType; //导入依赖的package包/类
private void generateLogon(Message otherLogon) throws FieldNotFound {
    final Message logon = messageFactory.create(sessionID.getBeginString(), MsgType.LOGON);
    logon.setInt(EncryptMethod.FIELD, EncryptMethod.NONE_OTHER);
    if (state.isResetReceived()) {
        logon.setBoolean(ResetSeqNumFlag.FIELD, true);
    }
    logon.setInt(HeartBtInt.FIELD, otherLogon.getInt(HeartBtInt.FIELD));
    if (sessionID.isFIXT()) {
        logon.setField(senderDefaultApplVerID);
    }
    if (enableLastMsgSeqNumProcessed) {
        logon.getHeader().setInt(LastMsgSeqNumProcessed.FIELD,
                otherLogon.getHeader().getInt(MsgSeqNum.FIELD));
    }
    initializeHeader(logon.getHeader());
    //field 789
    if (enableNextExpectedMsgSeqNum) {
        //the expected target num will be incremented one the other logon has been processed
        logon.setInt(NextExpectedMsgSeqNum.FIELD, getExpectedTargetNum() + 1);
    }
    sendViaFixFilter(logon, 0);
    state.setLogonSent(true);
}
 
开发者ID:fix-protocol-tools,项目名称:STAFF,代码行数:24,代码来源:Session.java

示例13: encode

import quickfix.field.MsgType; //导入依赖的package包/类
private static void encode(MessageBuilder mb, RawMessageAssembler asm, SessionID sessionID, OutputChannel out) throws IOException {
    mb.clear();
    mb.setMessageType(MsgType.ORDER_SINGLE);
    mb.add(FixTags.SenderLocationID, SENDER_LOCATION_ID);
    mb.add(FixTags.Account, ACCOUNT);
    mb.add(FixTags.ClOrdID, ORDER_ID);
    mb.add(FixTags.HandlInst, HandlInst.AUTOMATED_EXECUTION_ORDER_PRIVATE);
    mb.add(FixTags.OrderQty, QUANTITY);
    mb.add(FixTags.OrdType, OrdType.LIMIT);
    mb.add(FixTags.Price, PRICE);
    mb.add(FixTags.Side, Side.BUY);
    mb.add(FixTags.Symbol, SYMBOL);
    mb.add(FixTags.Text, TEXT);
    mb.add(FixTags.TimeInForce, TimeInForce.DAY);
    mb.addUTCTimestamp(FixTags.TransactTime, System.currentTimeMillis());
    mb.add(FixTags.SecurityDesc, SECURITY_DESCRIPTION);
    mb.add(FixTags.SecurityType, SecurityType.OPTION);
    asm.send(sessionID, MSG_SEQ_NUM, mb, null, RealTimeSource.INSTANCE.currentTimeMillis(), out);
}
 
开发者ID:andymalakov,项目名称:f1x,代码行数:20,代码来源:Test_EncodingNewOrderSingle.java

示例14: onMessage

import quickfix.field.MsgType; //导入依赖的package包/类
private void onMessage(final Message message, final SessionID sessionID)
{
    messages.add(message);
    try
    {
        final String msgType = message.getHeader().getField(new MsgType()).getValue();
        if (MsgType.LOGOUT.equals(msgType))
        {
            logouts.add(sessionID);
        }
    }
    catch (FieldNotFound fieldNotFound)
    {
        LangUtil.rethrowUnchecked(fieldNotFound);
    }
}
 
开发者ID:real-logic,项目名称:fix-integration,代码行数:17,代码来源:FakeQuickFixApplication.java

示例15: onMessage

import quickfix.field.MsgType; //导入依赖的package包/类
@Override
public void onMessage(String direction, Message message, SessionID sessionId)
{
	try
	{
		MsgType msgType = (MsgType) message.getHeader().getField(
				new MsgType());
		MessagesTableModelData data = new MessagesTableModelData(
				new Date(), direction, QFixUtil.getSessionName(sessionId),
				message.toString(), msgType.getValue());
		addRow(data);
	} catch (FieldNotFound ex)
	{
		logger.error("An exception occured!", ex);
	}
}
 
开发者ID:jramoyo,项目名称:quickfix-messenger,代码行数:17,代码来源:MessagesTableModel.java


注:本文中的quickfix.field.MsgType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。