Search in sources :

Example 1 with SwiftMqCodec

use of com.rabbitmq.stream.codec.SwiftMqCodec in project rabbitmq-stream-java-client by rabbitmq.

the class ClientTest method publishConsumeComplexMessagesWithMessageImplementationAndSwiftMqCodec.

@Test
void publishConsumeComplexMessagesWithMessageImplementationAndSwiftMqCodec() {
    Codec codec = new SwiftMqCodec();
    Client publisher = cf.get(new Client.ClientParameters().codec(codec));
    publishConsumeComplexMessage(publisher, codec, i -> {
        byte[] body = ("message" + i).getBytes(StandardCharsets.UTF_8);
        Map<String, Object> applicationProperties = Collections.singletonMap("id", i);
        Message message = new Message() {

            @Override
            public boolean hasPublishingId() {
                return false;
            }

            @Override
            public long getPublishingId() {
                return 0;
            }

            @Override
            public byte[] getBodyAsBinary() {
                return body;
            }

            @Override
            public Object getBody() {
                return null;
            }

            @Override
            public Properties getProperties() {
                return null;
            }

            @Override
            public Map<String, Object> getApplicationProperties() {
                return applicationProperties;
            }

            @Override
            public Map<String, Object> getMessageAnnotations() {
                return null;
            }
        };
        return message;
    });
}
Also used : QpidProtonCodec(com.rabbitmq.stream.codec.QpidProtonCodec) SimpleCodec(com.rabbitmq.stream.codec.SimpleCodec) SwiftMqCodec(com.rabbitmq.stream.codec.SwiftMqCodec) ClientParameters(com.rabbitmq.stream.impl.Client.ClientParameters) SwiftMqCodec(com.rabbitmq.stream.codec.SwiftMqCodec) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with SwiftMqCodec

use of com.rabbitmq.stream.codec.SwiftMqCodec in project rabbitmq-stream-java-client by rabbitmq.

the class ClientTest method publishConsumeComplexMessageWithMessageBuilderAndSwiftMqCodec.

@Test
void publishConsumeComplexMessageWithMessageBuilderAndSwiftMqCodec() {
    Codec codec = new SwiftMqCodec();
    Client publisher = cf.get(new Client.ClientParameters().codec(codec));
    publishConsumeComplexMessage(publisher, codec, i -> publisher.messageBuilder().applicationProperties().entry("id", i).messageBuilder().addData(("message" + i).getBytes(StandardCharsets.UTF_8)).build());
}
Also used : QpidProtonCodec(com.rabbitmq.stream.codec.QpidProtonCodec) SimpleCodec(com.rabbitmq.stream.codec.SimpleCodec) SwiftMqCodec(com.rabbitmq.stream.codec.SwiftMqCodec) ClientParameters(com.rabbitmq.stream.impl.Client.ClientParameters) SwiftMqCodec(com.rabbitmq.stream.codec.SwiftMqCodec) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

QpidProtonCodec (com.rabbitmq.stream.codec.QpidProtonCodec)2 SimpleCodec (com.rabbitmq.stream.codec.SimpleCodec)2 SwiftMqCodec (com.rabbitmq.stream.codec.SwiftMqCodec)2 ClientParameters (com.rabbitmq.stream.impl.Client.ClientParameters)2 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2