Skip to content

Example Spring AMPQ RabbitMQ Stream plugin support to set the Super Stream Routing #3222

@ggreen

Description

@ggreen

An add example to the current producing to a super stream docs.

The current docs do not include the details to retrieve a routing key for super stream routing.

@bean
RabbitStreamTemplate streamTemplate(Environment env) {
RabbitStreamTemplate template = new RabbitStreamTemplate(env, "stream.queue1");
template.setSuperStreamRouting(message -> {
// some logic to return a String for the client's hashing algorithm
});
return template;
}

The ask is to add an example of using the message builder to put a routing key in the msg app properties and using that property in the RabbitStreamTemplate.setSuperStreamRouting

https://docs.spring.io/spring-amqp/reference/stream.html#producing-to-a-superstream

Example

@Bean RabbitStreamTemplate streamTemplate(Environment env) { var template = new RabbitStreamTemplate(env, superStreamName); template.setSuperStreamRouting(message -> { return message.getApplicationProperties().get(ROUTING_KEY).toString(); }); return template; } //SEND MESSAGE -> Add a routing key to a message using the rabbitStreamTemplate rabbitStreamTemplate.send(rabbitStreamTemplate .messageBuilder().addData(converter.convert(domainObject)) .applicationProperties().entry("ROUTING_KEY",domainObject.getId()) .messageBuilder().build()); 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions