Search in sources :

Example 1 with OpenWireFormat

use of org.apache.activemq.openwire.OpenWireFormat in project activemq-artemis by apache.

the class TcpTransportFactory method compositeConfigure.

@Override
public Transport compositeConfigure(Transport transport, WireFormat format, Map options) {
    TcpTransport tcpTransport = transport.narrow(TcpTransport.class);
    IntrospectionSupport.setProperties(tcpTransport, options);
    Map<String, Object> socketOptions = IntrospectionSupport.extractProperties(options, "socket.");
    tcpTransport.setSocketOptions(socketOptions);
    if (tcpTransport.isTrace()) {
        try {
            transport = TransportLoggerSupport.createTransportLogger(transport, tcpTransport.getLogWriterName(), tcpTransport.isDynamicManagement(), tcpTransport.isStartLogging(), tcpTransport.getJmxPort());
        } catch (Throwable e) {
            LOG.error("Could not create TransportLogger object for: " + tcpTransport.getLogWriterName() + ", reason: " + e, e);
        }
    }
    boolean useInactivityMonitor = "true".equals(getOption(options, "useInactivityMonitor", "true"));
    if (useInactivityMonitor && isUseInactivityMonitor(transport)) {
        transport = createInactivityMonitor(transport, format);
        IntrospectionSupport.setProperties(transport, options);
    }
    // Only need the WireFormatNegotiator if using openwire
    if (format instanceof OpenWireFormat) {
        transport = new WireFormatNegotiator(transport, (OpenWireFormat) format, tcpTransport.getMinmumWireFormatVersion());
    }
    return super.compositeConfigure(transport, format, options);
}
Also used : OpenWireFormat(org.apache.activemq.openwire.OpenWireFormat) WireFormatNegotiator(org.apache.activemq.transport.WireFormatNegotiator)

Example 2 with OpenWireFormat

use of org.apache.activemq.openwire.OpenWireFormat in project activemq-artemis by apache.

the class DataStructureTestSupport method createWireFormat.

protected WireFormat createWireFormat() {
    OpenWireFormat answer = new OpenWireFormat();
    answer.setCacheEnabled(cacheEnabled);
    return answer;
}
Also used : OpenWireFormat(org.apache.activemq.openwire.OpenWireFormat)

Example 3 with OpenWireFormat

use of org.apache.activemq.openwire.OpenWireFormat in project activemq-artemis by apache.

the class ActiveMQMessageTest method testConvertProperties.

public void testConvertProperties() throws Exception {
    org.apache.activemq.command.Message msg = new org.apache.activemq.command.Message() {

        @Override
        public org.apache.activemq.command.Message copy() {
            return null;
        }

        @Override
        public void beforeMarshall(WireFormat wireFormat) throws IOException {
            super.beforeMarshall(wireFormat);
        }

        @Override
        public byte getDataStructureType() {
            return 0;
        }

        @Override
        public Response visit(CommandVisitor visitor) throws Exception {
            return null;
        }

        @Override
        public void clearBody() throws JMSException {
        }

        @Override
        public void storeContent() {
        }

        @Override
        public void storeContentAndClear() {
        }
    };
    msg.setProperty("stringProperty", "string");
    msg.setProperty("byteProperty", Byte.valueOf("1"));
    msg.setProperty("shortProperty", Short.valueOf("1"));
    msg.setProperty("intProperty", Integer.valueOf("1"));
    msg.setProperty("longProperty", Long.valueOf("1"));
    msg.setProperty("floatProperty", Float.valueOf("1.1f"));
    msg.setProperty("doubleProperty", Double.valueOf("1.1"));
    msg.setProperty("booleanProperty", Boolean.TRUE);
    msg.setProperty("nullProperty", null);
    msg.beforeMarshall(new OpenWireFormat());
    Map<String, Object> properties = msg.getProperties();
    assertEquals(properties.get("stringProperty"), "string");
    assertEquals(((Byte) properties.get("byteProperty")).byteValue(), 1);
    assertEquals(((Short) properties.get("shortProperty")).shortValue(), 1);
    assertEquals(((Integer) properties.get("intProperty")).intValue(), 1);
    assertEquals(((Long) properties.get("longProperty")).longValue(), 1);
    assertEquals(((Float) properties.get("floatProperty")).floatValue(), 1.1f, 0);
    assertEquals(((Double) properties.get("doubleProperty")).doubleValue(), 1.1, 0);
    assertEquals(((Boolean) properties.get("booleanProperty")).booleanValue(), true);
    assertNull(properties.get("nullProperty"));
}
Also used : OpenWireFormat(org.apache.activemq.openwire.OpenWireFormat) Message(javax.jms.Message) CommandVisitor(org.apache.activemq.state.CommandVisitor) WireFormat(org.apache.activemq.wireformat.WireFormat) OpenWireFormat(org.apache.activemq.openwire.OpenWireFormat)

Example 4 with OpenWireFormat

use of org.apache.activemq.openwire.OpenWireFormat in project activemq-artemis by apache.

the class MulticastTransportTest method createProducer.

@Override
protected Transport createProducer() throws Exception {
    LOG.info("Producer using URI: " + multicastURI);
    // we are not using the TransportFactory as this assumes that
    // transports talk to a server using a WireFormat Negotiation step
    // rather than talking directly to each other
    OpenWireFormat wireFormat = createWireFormat();
    MulticastTransport transport = new MulticastTransport(wireFormat, new URI(multicastURI));
    transport.setLoopBackMode(false);
    transport.setSequenceGenerator(new IntSequenceGenerator());
    return new CommandJoiner(transport, wireFormat);
}
Also used : OpenWireFormat(org.apache.activemq.openwire.OpenWireFormat) IntSequenceGenerator(org.apache.activemq.util.IntSequenceGenerator) CommandJoiner(org.apache.activemq.transport.CommandJoiner) URI(java.net.URI)

Example 5 with OpenWireFormat

use of org.apache.activemq.openwire.OpenWireFormat in project activemq-artemis by apache.

the class MulticastTransportTest method createConsumer.

@Override
protected Transport createConsumer() throws Exception {
    OpenWireFormat wireFormat = createWireFormat();
    MulticastTransport transport = new MulticastTransport(wireFormat, new URI(multicastURI));
    transport.setLoopBackMode(false);
    transport.setSequenceGenerator(new IntSequenceGenerator());
    return new CommandJoiner(transport, wireFormat);
}
Also used : OpenWireFormat(org.apache.activemq.openwire.OpenWireFormat) IntSequenceGenerator(org.apache.activemq.util.IntSequenceGenerator) CommandJoiner(org.apache.activemq.transport.CommandJoiner) URI(java.net.URI)

Aggregations

OpenWireFormat (org.apache.activemq.openwire.OpenWireFormat)14 CommandJoiner (org.apache.activemq.transport.CommandJoiner)6 URI (java.net.URI)5 IntSequenceGenerator (org.apache.activemq.util.IntSequenceGenerator)4 IOException (java.io.IOException)2 File (java.io.File)1 HashMap (java.util.HashMap)1 Message (javax.jms.Message)1 ConnectionEntry (org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry)1 FilePendingQueueMessageStoragePolicy (org.apache.activemq.broker.region.policy.FilePendingQueueMessageStoragePolicy)1 VMPendingQueueMessageStoragePolicy (org.apache.activemq.broker.region.policy.VMPendingQueueMessageStoragePolicy)1 WireFormatInfo (org.apache.activemq.command.WireFormatInfo)1 CommandVisitor (org.apache.activemq.state.CommandVisitor)1 PersistenceAdapter (org.apache.activemq.store.PersistenceAdapter)1 JDBCPersistenceAdapter (org.apache.activemq.store.jdbc.JDBCPersistenceAdapter)1 KahaDBPersistenceAdapter (org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter)1 TransportListener (org.apache.activemq.transport.TransportListener)1 WireFormatNegotiator (org.apache.activemq.transport.WireFormatNegotiator)1 ResponseRedirectInterceptor (org.apache.activemq.transport.udp.ResponseRedirectInterceptor)1 UdpTransport (org.apache.activemq.transport.udp.UdpTransport)1