Java 类org.apache.camel.MultipleConsumersSupport 实例源码

项目:Camel    文件:DefaultCamelContext.java   
private boolean doCheckMultipleConsumerSupportClash(Endpoint endpoint, List<Endpoint> routeInputs) {
    // is multiple consumers supported
    boolean multipleConsumersSupported = false;
    if (endpoint instanceof MultipleConsumersSupport) {
        multipleConsumersSupported = ((MultipleConsumersSupport) endpoint).isMultipleConsumersSupported();
    }

    if (multipleConsumersSupported) {
        // multiple consumer allowed, so return true
        return true;
    }

    // check in progress list
    if (routeInputs.contains(endpoint)) {
        return false;
    }

    return true;
}
项目:Camel    文件:QuickfixjComponentTest.java   
@Test
public void createEndpointBeforeComponentStart() throws Exception {
    setUpComponent();

    settings.setString(sessionID, SessionFactory.SETTING_CONNECTION_TYPE, SessionFactory.INITIATOR_CONNECTION_TYPE);
    settings.setLong(sessionID, Initiator.SETTING_SOCKET_CONNECT_PORT, 1234);

    writeSettings(settings, true);

    // Should use cached QFJ engine
    Endpoint e1 = component.createEndpoint(getEndpointUri(settingsFile.getName(), null));
    assertThat(component.getProvisionalEngines().size(), is(1));
    assertThat(component.getProvisionalEngines().get(settingsFile.getName()), is(notNullValue()));
    assertThat(component.getProvisionalEngines().get(settingsFile.getName()).isInitialized(), is(true));
    assertThat(component.getProvisionalEngines().get(settingsFile.getName()).isStarted(), is(false));
    assertThat(component.getEngines().size(), is(0));
    assertThat(((QuickfixjEndpoint)e1).getSessionID(), is(nullValue()));

    writeSettings(settings, false);

    // Should use cached QFJ engine
    Endpoint e2 = component.createEndpoint(getEndpointUri(settingsFile2.getName(), null));
    assertThat(component.getProvisionalEngines().size(), is(2));
    assertThat(component.getProvisionalEngines().get(settingsFile.getName()), is(notNullValue()));
    assertThat(component.getProvisionalEngines().get(settingsFile.getName()).isInitialized(), is(true));
    assertThat(component.getProvisionalEngines().get(settingsFile.getName()).isStarted(), is(false));
    assertThat(component.getEngines().size(), is(0));
    assertThat(((QuickfixjEndpoint)e2).getSessionID(), is(nullValue()));

    // will start the component
    camelContext.start();

    assertThat(component.getProvisionalEngines().size(), is(0));
    assertThat(component.getEngines().size(), is(2));
    assertThat(component.getEngines().get(settingsFile.getName()).isInitialized(), is(true));
    assertThat(component.getEngines().get(settingsFile.getName()).isStarted(), is(true));

    // Move these too an endpoint testcase if one exists
    assertThat(e1.isSingleton(), is(true));
    assertThat(((MultipleConsumersSupport)e1).isMultipleConsumersSupported(), is(true));
    assertThat(e2.isSingleton(), is(true));
    assertThat(((MultipleConsumersSupport)e2).isMultipleConsumersSupported(), is(true));
}