How to set replyTo header with OutboundMessageBuilder

Options
radekm
radekm Member Posts: 23

Hi,

we're trying to use Python and new Java APIs but are we struggling to set replyTo header on outgoing messages.

In old Java API you can just call BytesMessage.setReplyTo. Is there a way to do it in Python and new Java APIs with OutboundMessageBuilder?

Thanks

Answers

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 494 admin
    Options

    Hey @radekm ! You can use the RequestReply message builder in the Python (and new Java) API to create a request-reply message requester/replier. Is this something that you can make use of? We have sample code for the request-reply pattern coming soon in the samples repo, but I put a snippet on this post here https://solace.community/discussion/1221/solace-python-api-for-request-reply-architecture if you want to get started. Let me know what your use-case is and I can hopefully shed more light on this !

  • radekm
    radekm Member Posts: 23
    Options

    Hi @Tamimi

    Thanks for the answer. I looked at the snipped for requestor but still don't see how to set replyTo topic. It seems the example sets only request_destination

    from solace.messaging.publisher.request_reply_message_publisher import RequestReplyMessagePublisher
    
    # Create a direct message requestor and register the error handler
    direct_requestor: RequestReplyMessagePublisher = messaging_service.request_reply() \
                            .create_request_reply_message_publisher_builder() \
                            .build()
    
    direct_requestor.start()
    
    outbound_msg = messaging_service.message_builder().build(f'\n{insert_your_message_here}')
    response = direct_requestor_blocking.publish_await_response(request_message=outbound_msg, \
                                                                        request_destination=destination_topic, \
                                                                        reply_timeout=10000)
    

    Unfortunately our system expects that replies are send to {replier-service-name}/to/{requestor-service-name}/{subject} so we can easily filter all replies by source or destination service or by subject