Search in sources :

Example 1 with Subject

use of quickfix.field.Subject in project camel by apache.

the class QuickfixjComponentTest method messagePublication.

@Test
public void messagePublication() throws Exception {
    setUpComponent();
    // Create settings file with both acceptor and initiator
    SessionSettings settings = new SessionSettings();
    settings.setString(Acceptor.SETTING_SOCKET_ACCEPT_PROTOCOL, ProtocolFactory.getTypeString(ProtocolFactory.VM_PIPE));
    settings.setString(Initiator.SETTING_SOCKET_CONNECT_PROTOCOL, ProtocolFactory.getTypeString(ProtocolFactory.VM_PIPE));
    settings.setBool(Session.SETTING_USE_DATA_DICTIONARY, false);
    SessionID acceptorSessionID = new SessionID(FixVersions.BEGINSTRING_FIX44, "ACCEPTOR", "INITIATOR");
    settings.setString(acceptorSessionID, SessionFactory.SETTING_CONNECTION_TYPE, SessionFactory.ACCEPTOR_CONNECTION_TYPE);
    settings.setLong(acceptorSessionID, Acceptor.SETTING_SOCKET_ACCEPT_PORT, 1234);
    setSessionID(settings, acceptorSessionID);
    SessionID initiatorSessionID = new SessionID(FixVersions.BEGINSTRING_FIX44, "INITIATOR", "ACCEPTOR");
    settings.setString(initiatorSessionID, SessionFactory.SETTING_CONNECTION_TYPE, SessionFactory.INITIATOR_CONNECTION_TYPE);
    settings.setLong(initiatorSessionID, Initiator.SETTING_SOCKET_CONNECT_PORT, 1234);
    settings.setLong(initiatorSessionID, Initiator.SETTING_RECONNECT_INTERVAL, 1);
    setSessionID(settings, initiatorSessionID);
    writeSettings(settings, true);
    Endpoint endpoint = component.createEndpoint(getEndpointUri(settingsFile.getName(), null));
    // Start the component and wait for the FIX sessions to be logged on
    final CountDownLatch logonLatch = new CountDownLatch(2);
    final CountDownLatch messageLatch = new CountDownLatch(2);
    Consumer consumer = endpoint.createConsumer(new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            QuickfixjEventCategory eventCategory = (QuickfixjEventCategory) exchange.getIn().getHeader(QuickfixjEndpoint.EVENT_CATEGORY_KEY);
            if (eventCategory == QuickfixjEventCategory.SessionLogon) {
                logonLatch.countDown();
            } else if (eventCategory == QuickfixjEventCategory.AppMessageReceived) {
                messageLatch.countDown();
            }
        }
    });
    ServiceHelper.startService(consumer);
    // will start the component
    camelContext.start();
    assertTrue("Session not created", logonLatch.await(5000, TimeUnit.MILLISECONDS));
    Endpoint producerEndpoint = component.createEndpoint(getEndpointUri(settingsFile.getName(), acceptorSessionID));
    Producer producer = producerEndpoint.createProducer();
    // FIX message to send
    Email email = new Email(new EmailThreadID("ID"), new EmailType(EmailType.NEW), new Subject("Test"));
    Exchange exchange = producer.createExchange(ExchangePattern.InOnly);
    exchange.getIn().setBody(email);
    producer.process(exchange);
    // Produce with no session ID specified, session ID must be in message
    Producer producer2 = endpoint.createProducer();
    email.getHeader().setString(SenderCompID.FIELD, acceptorSessionID.getSenderCompID());
    email.getHeader().setString(TargetCompID.FIELD, acceptorSessionID.getTargetCompID());
    producer2.process(exchange);
    assertTrue("Messages not received", messageLatch.await(5000, TimeUnit.MILLISECONDS));
}
Also used : Processor(org.apache.camel.Processor) Email(quickfix.fix44.Email) EmailType(quickfix.field.EmailType) EmailThreadID(quickfix.field.EmailThreadID) CountDownLatch(java.util.concurrent.CountDownLatch) SessionSettings(quickfix.SessionSettings) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) Subject(quickfix.field.Subject) Exchange(org.apache.camel.Exchange) Endpoint(org.apache.camel.Endpoint) Consumer(org.apache.camel.Consumer) Producer(org.apache.camel.Producer) SessionID(quickfix.SessionID) Test(org.junit.Test)

Example 2 with Subject

use of quickfix.field.Subject in project camel by apache.

the class TestSupport method createEmailMessage.

public static Email createEmailMessage(String subject) {
    Email email = new Email(new EmailThreadID("ID"), new EmailType(EmailType.NEW), new Subject(subject));
    Email.LinesOfText text = new Email.LinesOfText();
    text.set(new Text("Content"));
    email.addGroup(text);
    return email;
}
Also used : Email(quickfix.fix42.Email) EmailType(quickfix.field.EmailType) Text(quickfix.field.Text) EmailThreadID(quickfix.field.EmailThreadID) Subject(quickfix.field.Subject)

Example 3 with Subject

use of quickfix.field.Subject in project wildfly-camel by wildfly-extras.

the class QuickfixIntegrationTest method createEmailMessage.

private Email createEmailMessage(String subject) {
    Email email = new Email(new EmailThreadID("ID"), new EmailType(EmailType.NEW), new Subject(subject));
    Email.LinesOfText text = new Email.LinesOfText();
    text.set(new Text("Content"));
    email.addGroup(text);
    return email;
}
Also used : Email(quickfix.fix42.Email) EmailType(quickfix.field.EmailType) Text(quickfix.field.Text) EmailThreadID(quickfix.field.EmailThreadID) Subject(quickfix.field.Subject)

Aggregations

EmailThreadID (quickfix.field.EmailThreadID)3 EmailType (quickfix.field.EmailType)3 Subject (quickfix.field.Subject)3 Text (quickfix.field.Text)2 Email (quickfix.fix42.Email)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Consumer (org.apache.camel.Consumer)1 Endpoint (org.apache.camel.Endpoint)1 Exchange (org.apache.camel.Exchange)1 Processor (org.apache.camel.Processor)1 Producer (org.apache.camel.Producer)1 Test (org.junit.Test)1 SessionID (quickfix.SessionID)1 SessionSettings (quickfix.SessionSettings)1 Email (quickfix.fix44.Email)1