Search in sources :

Example 6 with SessionSettings

use of quickfix.SessionSettings in project camel by apache.

the class QuickfixjEngineTest method setUp.

@Before
public void setUp() throws Exception {
    settingsFile = File.createTempFile("quickfixj_test_", ".cfg");
    tempdir = settingsFile.getParentFile();
    URL[] urls = new URL[] { tempdir.toURI().toURL() };
    contextClassLoader = Thread.currentThread().getContextClassLoader();
    ClassLoader testClassLoader = new URLClassLoader(urls, contextClassLoader);
    Thread.currentThread().setContextClassLoader(testClassLoader);
    sessionID = new SessionID(FixVersions.BEGINSTRING_FIX44, "FOO", "BAR");
    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);
    settings.setBool(QuickfixjEngine.SETTING_USE_JMX, false);
    TestSupport.setSessionID(settings, sessionID);
}
Also used : URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) SessionID(quickfix.SessionID) URL(java.net.URL) SessionSettings(quickfix.SessionSettings) Before(org.junit.Before)

Example 7 with SessionSettings

use of quickfix.SessionSettings in project camel by apache.

the class QuickfixjSpringTest method configureInSpring.

@Test
public void configureInSpring() throws Exception {
    if (isJava16()) {
        // cannot test on java 1.6
        return;
    }
    SessionID sessionID = new SessionID("FIX.4.2:INITIATOR->ACCEPTOR");
    QuickfixjConfiguration configuration = context.getRegistry().lookupByNameAndType("quickfixjConfiguration", QuickfixjConfiguration.class);
    SessionSettings springSessionSettings = configuration.createSessionSettings();
    Properties sessionProperties = springSessionSettings.getSessionProperties(sessionID, true);
    assertThat(sessionProperties.get("ConnectionType").toString(), CoreMatchers.is("initiator"));
    assertThat(sessionProperties.get("SocketConnectProtocol").toString(), CoreMatchers.is("VM_PIPE"));
    QuickfixjComponent component = context.getComponent("quickfix", QuickfixjComponent.class);
    assertThat(component.isLazyCreateEngines(), is(false));
    QuickfixjEngine engine = component.getEngines().values().iterator().next();
    assertThat(engine.isInitialized(), is(true));
    QuickfixjComponent lazyComponent = context.getComponent("lazyQuickfix", QuickfixjComponent.class);
    assertThat(lazyComponent.isLazyCreateEngines(), is(true));
    QuickfixjEngine lazyEngine = lazyComponent.getEngines().values().iterator().next();
    assertThat(lazyEngine.isInitialized(), is(false));
    assertThat(engine.getMessageFactory(), is(instanceOf(CustomMessageFactory.class)));
}
Also used : Properties(java.util.Properties) SessionID(quickfix.SessionID) SessionSettings(quickfix.SessionSettings) Test(org.junit.Test)

Example 8 with SessionSettings

use of quickfix.SessionSettings in project camel by apache.

the class QuickfixjComponent method createEndpoint.

@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
    // Look up the engine instance based on the settings file ("remaining")
    QuickfixjEngine engine;
    synchronized (engineInstancesLock) {
        QuickfixjEndpoint endpoint = endpoints.get(uri);
        if (endpoint == null) {
            engine = engines.get(remaining);
            if (engine == null) {
                engine = provisionalEngines.get(remaining);
            }
            if (engine == null) {
                QuickfixjConfiguration configuration = configurations.get(remaining);
                SessionSettings settings;
                if (configuration != null) {
                    settings = configuration.createSessionSettings();
                } else {
                    settings = QuickfixjEngine.loadSettings(remaining);
                }
                Boolean lazyCreateEngineForEndpoint = super.getAndRemoveParameter(parameters, PARAMETER_LAZY_CREATE_ENGINE, Boolean.TYPE);
                if (lazyCreateEngineForEndpoint == null) {
                    lazyCreateEngineForEndpoint = isLazyCreateEngines();
                }
                engine = new QuickfixjEngine(uri, settings, messageStoreFactory, logFactory, messageFactory, lazyCreateEngineForEndpoint);
                // automatic later when CamelContext has been started using the StartupListener
                if (getCamelContext().getStatus().isStarted()) {
                    startQuickfixjEngine(engine);
                    engines.put(remaining, engine);
                } else {
                    // engines to be started later
                    provisionalEngines.put(remaining, engine);
                }
            }
            endpoint = new QuickfixjEndpoint(engine, uri, this);
            endpoint.setConfigurationName(remaining);
            endpoint.setLazyCreateEngine(engine.isLazy());
            engine.addEventListener(endpoint);
            endpoints.put(uri, endpoint);
        }
        return endpoint;
    }
}
Also used : SessionSettings(quickfix.SessionSettings)

Example 9 with SessionSettings

use of quickfix.SessionSettings in project camel by apache.

the class QuickfixjComponentTest method setUp.

@Before
public void setUp() throws Exception {
    settingsFile = File.createTempFile("quickfixj_test_", ".cfg");
    settingsFile2 = File.createTempFile("quickfixj_test2_", ".cfg");
    tempdir = settingsFile.getParentFile();
    tempdir2 = settingsFile.getParentFile();
    URL[] urls = new URL[] { tempdir.toURI().toURL(), tempdir2.toURI().toURL() };
    sessionID = new SessionID(FixVersions.BEGINSTRING_FIX44, "FOO", "BAR");
    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);
    setSessionID(settings, sessionID);
    contextClassLoader = Thread.currentThread().getContextClassLoader();
    ClassLoader testClassLoader = new URLClassLoader(urls, contextClassLoader);
    Thread.currentThread().setContextClassLoader(testClassLoader);
}
Also used : URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) SessionID(quickfix.SessionID) URL(java.net.URL) SessionSettings(quickfix.SessionSettings) Before(org.junit.Before)

Example 10 with SessionSettings

use of quickfix.SessionSettings in project camel by apache.

the class QuickfixjConvertersTest method createSession.

private void createSession(SessionID sessionID) throws IOException, ConfigError, FieldConvertError, JMException, Exception {
    SessionSettings settings = new SessionSettings();
    settings.setString(Acceptor.SETTING_SOCKET_ACCEPT_PROTOCOL, ProtocolFactory.getTypeString(ProtocolFactory.VM_PIPE));
    settings.setString(sessionID, SessionFactory.SETTING_CONNECTION_TYPE, SessionFactory.ACCEPTOR_CONNECTION_TYPE);
    settings.setLong(sessionID, Acceptor.SETTING_SOCKET_ACCEPT_PORT, 1234);
    TestSupport.setSessionID(settings, sessionID);
    TestSupport.writeSettings(settings, settingsFile);
    quickfixjEngine = new QuickfixjEngine("quickfix:test", settingsFile.getName());
    quickfixjEngine.start();
}
Also used : SessionSettings(quickfix.SessionSettings)

Aggregations

SessionSettings (quickfix.SessionSettings)10 SessionID (quickfix.SessionID)6 URL (java.net.URL)3 URLClassLoader (java.net.URLClassLoader)3 Before (org.junit.Before)3 Test (org.junit.Test)3 Date (java.util.Date)2 Properties (java.util.Properties)2 LogFactory (quickfix.LogFactory)2 MessageStore (quickfix.MessageStore)2 MessageStoreFactory (quickfix.MessageStoreFactory)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)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