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


Java FailedToCreateProducerException类代码示例

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


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

示例1: acquireProducer

import org.apache.camel.FailedToCreateProducerException; //导入依赖的package包/类
@Override
public Producer acquireProducer(Endpoint endpoint) {
    // always create a new producer
    Producer answer;
    try {
        answer = endpoint.createProducer();
        if (getCamelContext().isStartingRoutes() && answer.isSingleton()) {
            // if we are currently starting a route, then add as service and enlist in JMX
            // - but do not enlist non-singletons in JMX
            // - note addService will also start the service
            getCamelContext().addService(answer);
        } else {
            // must then start service so producer is ready to be used
            ServiceHelper.startService(answer);
        }
    } catch (Exception e) {
        throw new FailedToCreateProducerException(endpoint, e);
    }
    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:EmptyProducerCache.java

示例2: testRoutingSlipCreateProducerFailed

import org.apache.camel.FailedToCreateProducerException; //导入依赖的package包/类
public void testRoutingSlipCreateProducerFailed() throws Exception {
    // no inflight
    assertEquals(0, context.getInflightRepository().size());

    template.sendBodyAndHeader("direct:start", "Hello World", "foo", "log:foo");

    // no inflight
    assertEquals(0, context.getInflightRepository().size());

    // those 2 options not allowed together
    try {
        template.sendBodyAndHeader("direct:start", "Hello World", "foo", "file://target/test?fileExist=Append&tempPrefix=hello");
        fail("Should fail");
    } catch (CamelExecutionException e) {
        assertIsInstanceOf(FailedToCreateProducerException.class, e.getCause());
    }

    // no inflight
    assertEquals(0, context.getInflightRepository().size());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:RoutingSlipCreateProducerFailedTest.java

示例3: testCreateSerlvetEndpointProducer

import org.apache.camel.FailedToCreateProducerException; //导入依赖的package包/类
@Test
public void testCreateSerlvetEndpointProducer() throws Exception {
    if (!startCamelContext) {
        // don't test it with web.xml configure
        return;
    }
    try {
        context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("direct:start").to("servlet:///testworld");
            }
        });
        fail("Excepts exception here");
    } catch (FailedToCreateRouteException ex) {
        assertTrue("Get a wrong exception.", ex.getCause() instanceof FailedToCreateProducerException);
        assertTrue("Get a wrong cause of exception.", ex.getCause().getCause() instanceof UnsupportedOperationException);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:HttpClientRouteTest.java

示例4: testConnectionOnStartup

import org.apache.camel.FailedToCreateProducerException; //导入依赖的package包/类
/**
 * Pre tests the connection before starting the listening.
 * <p/>
 * In case of connection failure the exception is thrown which prevents Camel from starting.
 *
 * @throws FailedToCreateProducerException is thrown if testing the connection failed
 */
protected void testConnectionOnStartup() throws FailedToCreateProducerException {
    try {
        CamelJmsTemplate template = (CamelJmsTemplate) getInOnlyTemplate();

        if (log.isDebugEnabled()) {
            log.debug("Testing JMS Connection on startup for destination: " + template.getDefaultDestinationName());
        }

        Connection conn = template.getConnectionFactory().createConnection();
        JmsUtils.closeConnection(conn);

        log.debug("Successfully tested JMS Connection on startup for destination: " + template.getDefaultDestinationName());
    } catch (Exception e) {
        throw new FailedToCreateProducerException(getEndpoint(), e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:JmsProducer.java

示例5: testConnectionOnStartupProducerTest

import org.apache.camel.FailedToCreateProducerException; //导入依赖的package包/类
@Test
public void testConnectionOnStartupProducerTest() throws Exception {
    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").to("activemq:queue:foo?testConnectionOnStartup=true");
        }
    });

    try {
        context.start();
        fail("Should have thrown an exception");
    } catch (FailedToCreateProducerException e) {
        assertTrue(e.getMessage().startsWith("Failed to create Producer for endpoint: activemq://queue:foo?testConnectionOnStartup=true."));
        assertTrue(e.getMessage().contains("java.net.ConnectException"));
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:JmsTestConnectionOnStartupTest.java

示例6: clientFailsToConnectUsingWrongCredentialsToNewlyStartedBroker

import org.apache.camel.FailedToCreateProducerException; //导入依赖的package包/类
@Test
public void clientFailsToConnectUsingWrongCredentialsToNewlyStartedBroker()
		throws Exception {
	String user = "someUser";
	sut = mqttMain().withBrokerPort(freePort()).withBrokerUser(user)
			.withBrokerPassword("theBrokersPassword").withClientUser(user)
			.withClientPassword("notTheBrokersPassword");
	exceptions.expect(FailedToCreateProducerException.class);
	exceptions.expectMessage("CONNECTION_REFUSED_BAD_USERNAME_OR_PASSWORD");
	sut.connectToMqttBroker();
}
 
开发者ID:Ardulink,项目名称:Ardulink-2,代码行数:12,代码来源:MqttMainStandaloneIntegrationTest.java

示例7: doGetProducer

import org.apache.camel.FailedToCreateProducerException; //导入依赖的package包/类
protected synchronized Producer doGetProducer(Endpoint endpoint, boolean pooled) {
    String key = endpoint.getEndpointUri();
    Producer answer = producers.get(key);
    if (pooled && answer == null) {
        // try acquire from connection pool
        answer = pool.acquire(endpoint);
    }

    if (answer == null) {
        // create a new producer
        try {
            answer = endpoint.createProducer();
            // add as service which will also start the service
            // (false => we and handling the lifecycle of the producer in this cache)
            getCamelContext().addService(answer, false);
        } catch (Exception e) {
            throw new FailedToCreateProducerException(endpoint, e);
        }

        // add producer to cache or pool if applicable
        if (pooled && answer instanceof ServicePoolAware) {
            LOG.debug("Adding to producer service pool with key: {} for producer: {}", endpoint, answer);
            answer = pool.addAndAcquire(endpoint, answer);
        } else if (answer.isSingleton()) {
            LOG.debug("Adding to producer cache with key: {} for producer: {}", endpoint, answer);
            producers.put(key, answer);
        }
    }

    if (answer != null) {
        // record statistics
        if (extendedStatistics) {
            statistics.onHit(key);
        }
    }

    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:39,代码来源:ProducerCache.java

示例8: buildProducer

import org.apache.camel.FailedToCreateProducerException; //导入依赖的package包/类
protected GenericFileProducer<FTPFile> buildProducer() {
    try {
        return new RemoteFileProducer<FTPFile>(this, createRemoteFileOperations());
    } catch (Exception e) {
        throw new FailedToCreateProducerException(this, e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:FtpEndpoint.java

示例9: testInvalidConfiguration

import org.apache.camel.FailedToCreateProducerException; //导入依赖的package包/类
@Test
public void testInvalidConfiguration() throws Exception {
    try {
        template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Temporary", "Hello World");
        fail("Should have thrown exception");
    } catch (CamelExecutionException e) {
        assertIsInstanceOf(FailedToCreateProducerException.class, e.getCause());
        assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
        assertEquals("ReplyToType Temporary is not supported when replyTo bar is also configured.", e.getCause().getCause().getMessage());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:JmsRequestReplyExclusiveReplyToTest.java

示例10: afterPropertiesSet

import org.apache.camel.FailedToCreateProducerException; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception {
    if (endpoint == null) {
        getCamelContext();
        if (getServiceUrl() == null && getServiceRef() == null) {
            throw new IllegalArgumentException("serviceUrl or serviceRef must be specified.");
        }
        if (getServiceInterface() == null) {
            throw new IllegalArgumentException("serviceInterface must be specified.");
        }

        // lookup endpoint or we have the url for it
        if (getServiceRef() != null) {
            endpoint = getCamelContext().getRegistry().lookupByNameAndType(getServiceRef(), Endpoint.class);
        } else {
            endpoint = getCamelContext().getEndpoint(getServiceUrl());
        }

        if (endpoint == null) {
            throw new IllegalArgumentException("Could not resolve endpoint: " + getServiceUrl());
        }
    }

    // binding is enabled by default
    boolean bind = getBinding() != null ? getBinding() : true;

    try {
        // need to start endpoint before we create producer
        ServiceHelper.startService(endpoint);
        producer = endpoint.createProducer();
        // add and start producer
        getCamelContext().addService(producer, true, true);
        Class<?> clazz = blueprintContainer.loadClass(getServiceInterface());
        serviceProxy = ProxyHelper.createProxy(endpoint, bind, producer, clazz);
    } catch (Exception e) {
        throw new FailedToCreateProducerException(endpoint, e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:38,代码来源:CamelProxyFactoryBean.java

示例11: afterPropertiesSet

import org.apache.camel.FailedToCreateProducerException; //导入依赖的package包/类
@Override
public void afterPropertiesSet() {
    if (endpoint == null) {
        if (ObjectHelper.isNotEmpty(camelContextId)) {
            camelContext = CamelContextResolverHelper.getCamelContextWithId(applicationContext, camelContextId);
        }
        if (camelContext == null) {
            throw new IllegalArgumentException("camelContext or camelContextId must be specified");
        }
        
        if (getServiceUrl() == null && getServiceRef() == null) {
            throw new IllegalArgumentException("serviceUrl or serviceRef must be specified.");
        }

        // lookup endpoint or we have the url for it
        if (getServiceRef() != null) {
            endpoint = camelContext.getRegistry().lookupByNameAndType(getServiceRef(), Endpoint.class);
        } else {
            endpoint = camelContext.getEndpoint(getServiceUrl());
        }

        if (endpoint == null) {
            throw new IllegalArgumentException("Could not resolve endpoint: " + getServiceUrl());
        }
    }

    // binding is enabled by default
    boolean bind = getBinding() != null ? getBinding() : true;

    try {
        // need to start endpoint before we create producer
        ServiceHelper.startService(endpoint);
        producer = endpoint.createProducer();
        // add and start producer
        camelContext.addService(producer, true, true);
        serviceProxy = ProxyHelper.createProxy(endpoint, bind, producer, getServiceInterface());
    } catch (Exception e) {
        throw new FailedToCreateProducerException(endpoint, e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:41,代码来源:CamelProxyFactoryBean.java

示例12: testAuthMethodPriorityInvalid

import org.apache.camel.FailedToCreateProducerException; //导入依赖的package包/类
@Test
public void testAuthMethodPriorityInvalid() throws Exception {
    try {
        template.requestBody("http://localhost:{{port}}/test?authMethod=Basic&authMethodPriority=Basic,foo&authUsername=donald&authPassword=duck", "Hello World", String.class);
        fail("Should have thrown an exception");
    } catch (FailedToCreateProducerException e) {
        IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause().getCause());
        //JAXB 2.2 uses a slightly different message
        boolean b = cause.getMessage().contains("No enum const")
            && cause.getMessage().contains("org.apache.camel.component.http.AuthMethod.foo");
        assertTrue("Bad fault message: " + cause.getMessage(), b);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:HttpAuthMethodPriorityTest.java

示例13: initReplyManager

import org.apache.camel.FailedToCreateProducerException; //导入依赖的package包/类
protected void initReplyManager() {
    if (!started.get()) {
        synchronized (this) {
            if (started.get()) {
                return;
            }

            // must use the classloader from the application context when creating reply manager,
            // as it should inherit the classloader from app context and not the current which may be
            // a different classloader
            ClassLoader current = Thread.currentThread().getContextClassLoader();
            ClassLoader ac = endpoint.getCamelContext().getApplicationContextClassLoader();
            try {
                if (ac != null) {
                    Thread.currentThread().setContextClassLoader(ac);
                }
                // validate that replyToType and replyTo is configured accordingly
                if (endpoint.getReplyToType() != null) {
                    // setting temporary with a fixed replyTo is not supported
                    if (endpoint.getReplyTo() != null && endpoint.getReplyToType().equals(ReplyToType.Temporary.name())) {
                        throw new IllegalArgumentException("ReplyToType " + ReplyToType.Temporary
                                + " is not supported when replyTo " + endpoint.getReplyTo() + " is also configured.");
                    }
                }

                if (endpoint.getReplyTo() != null) {
                    replyManager = createReplyManager(endpoint.getReplyTo());
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Using JmsReplyManager: {} to process replies from: {}", replyManager, endpoint.getReplyTo());
                    }
                } else {
                    replyManager = createReplyManager();
                    LOG.debug("Using JmsReplyManager: {} to process replies from temporary queue", replyManager);
                }
            } catch (Exception e) {
                throw new FailedToCreateProducerException(endpoint, e);
            } finally {
                if (ac != null) {
                    Thread.currentThread().setContextClassLoader(current);
                }
            }
            started.set(true);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:46,代码来源:JmsProducer.java

示例14: initReplyManager

import org.apache.camel.FailedToCreateProducerException; //导入依赖的package包/类
protected void initReplyManager() {
    if (!started.get()) {
        synchronized (this) {
            if (started.get()) {
                return;
            }
            log.debug("Starting reply manager");
            // must use the classloader from the application context when creating reply manager,
            // as it should inherit the classloader from app context and not the current which may be
            // a different classloader
            ClassLoader current = Thread.currentThread().getContextClassLoader();
            ClassLoader ac = getEndpoint().getCamelContext().getApplicationContextClassLoader();
            try {
                if (ac != null) {
                    Thread.currentThread().setContextClassLoader(ac);
                }
                // validate that replyToType and replyTo is configured accordingly
                if (getEndpoint().getReplyToType() != null) {
                    // setting temporary with a fixed replyTo is not supported
                    if (getEndpoint().getReplyTo() != null && getEndpoint().getReplyToType().equals(ReplyToType.Temporary.name())) {
                        throw new IllegalArgumentException("ReplyToType " + ReplyToType.Temporary
                                        + " is not supported when replyTo " + getEndpoint().getReplyTo() + " is also configured.");
                    }
                }

                if (getEndpoint().getReplyTo() != null) {
                    // specifying reply queues is not currently supported
                    throw new IllegalArgumentException("Specifying replyTo " + getEndpoint().getReplyTo() + " is currently not supported.");
                } else {
                    replyManager = createReplyManager();
                    log.debug("Using RabbitMQReplyManager: {} to process replies from temporary queue", replyManager);
                }
            } catch (Exception e) {
                throw new FailedToCreateProducerException(getEndpoint(), e);
            } finally {
                if (ac != null) {
                    Thread.currentThread().setContextClassLoader(current);
                }
            }
            started.set(true);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:44,代码来源:RabbitMQProducer.java


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