Search in sources :

Example 1 with XBeanBrokerFactory

use of org.apache.activemq.xbean.XBeanBrokerFactory in project activemq-artemis by apache.

the class RequestReplyNoAdvisoryNetworkTest method testNonAdvisoryNetworkRequestReplyXmlConfig.

public void testNonAdvisoryNetworkRequestReplyXmlConfig() throws Exception {
    final String xmlConfigString = new String("<beans" + " xmlns=\"http://www.springframework.org/schema/beans\"" + " xmlns:amq=\"http://activemq.apache.org/schema/core\"" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + " xsi:schemaLocation=\"http://www.springframework.org/schema/beans" + " http://www.springframework.org/schema/beans/spring-beans-2.0.xsd" + " http://activemq.apache.org/schema/core" + " http://activemq.apache.org/schema/core/activemq-core.xsd\">" + "  <broker xmlns=\"http://activemq.apache.org/schema/core\" id=\"broker\"" + "    allowTempAutoCreationOnSend=\"true\" schedulePeriodForDestinationPurge=\"1000\"" + "    brokerName=\"%HOST%\" persistent=\"false\" advisorySupport=\"false\" useJmx=\"false\" >" + "   <destinationPolicy>" + "    <policyMap>" + "     <policyEntries>" + "      <policyEntry optimizedDispatch=\"true\"  gcInactiveDestinations=\"true\" gcWithNetworkConsumers=\"true\" inactiveTimoutBeforeGC=\"1000\">" + "       <destination>" + "        <tempQueue physicalName=\"" + replyQWildcard.getPhysicalName() + "\"/>" + "       </destination>" + "      </policyEntry>" + "     </policyEntries>" + "    </policyMap>" + "   </destinationPolicy>" + "   <networkConnectors>" + "    <networkConnector uri=\"multicast://default\">" + "     <staticallyIncludedDestinations>" + "      <queue physicalName=\"" + sendQ.getPhysicalName() + "\"/>" + "      <tempQueue physicalName=\"" + replyQWildcard.getPhysicalName() + "\"/>" + "     </staticallyIncludedDestinations>" + "    </networkConnector>" + "   </networkConnectors>" + "   <transportConnectors>" + "     <transportConnector uri=\"tcp://0.0.0.0:0\" discoveryUri=\"multicast://default\" />" + "   </transportConnectors>" + "  </broker>" + "</beans>");
    final String localProtocolScheme = "inline";
    URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {

        @Override
        public URLStreamHandler createURLStreamHandler(String protocol) {
            if (localProtocolScheme.equalsIgnoreCase(protocol)) {
                return new URLStreamHandler() {

                    @Override
                    protected URLConnection openConnection(URL u) throws IOException {
                        return new URLConnection(u) {

                            @Override
                            public void connect() throws IOException {
                            }

                            @Override
                            public InputStream getInputStream() throws IOException {
                                return new ByteArrayInputStream(xmlConfigString.replace("%HOST%", url.getFile()).getBytes(StandardCharsets.UTF_8));
                            }
                        };
                    }
                };
            }
            return null;
        }
    });
    a = new XBeanBrokerFactory().createBroker(new URI("xbean:" + localProtocolScheme + ":A"));
    b = new XBeanBrokerFactory().createBroker(new URI("xbean:" + localProtocolScheme + ":B"));
    brokers.add(a);
    brokers.add(b);
    doTestNonAdvisoryNetworkRequestReply();
}
Also used : URLStreamHandler(java.net.URLStreamHandler) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) URLStreamHandlerFactory(java.net.URLStreamHandlerFactory) IOException(java.io.IOException) URI(java.net.URI) URL(java.net.URL) URLConnection(java.net.URLConnection) XBeanBrokerFactory(org.apache.activemq.xbean.XBeanBrokerFactory)

Example 2 with XBeanBrokerFactory

use of org.apache.activemq.xbean.XBeanBrokerFactory in project activemq-artemis by apache.

the class CreateDestinationsOnStartupViaXBeanTest method createBroker.

@Override
protected BrokerService createBroker() throws Exception {
    XBeanBrokerFactory factory = new XBeanBrokerFactory();
    BrokerService answer = factory.createBroker(new URI(getBrokerConfigUri()));
    // lets disable persistence as we are a test
    answer.setPersistent(false);
    return answer;
}
Also used : URI(java.net.URI) XBeanBrokerFactory(org.apache.activemq.xbean.XBeanBrokerFactory)

Aggregations

URI (java.net.URI)2 XBeanBrokerFactory (org.apache.activemq.xbean.XBeanBrokerFactory)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1 URLStreamHandler (java.net.URLStreamHandler)1 URLStreamHandlerFactory (java.net.URLStreamHandlerFactory)1