Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOL-112353: Start and termination of a RequestReplyMessagePublisher integration tests #42

Merged
merged 9 commits into from
Mar 15, 2024
43 changes: 43 additions & 0 deletions test/helpers/builder_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,46 @@ func NewMessage(messagingService solace.MessagingService, payload ...string) mes
ExpectWithOffset(1, err).ToNot(HaveOccurred(), "An error occurred while building a new outbound message")
return msg
}

// NewRequestReplyMessageReceiver function
func NewRequestReplyMessageReceiver(
messagingService solace.MessagingService,
subscription *resource.TopicSubscription,
configurationProviders ...config.ReceiverPropertiesConfigurationProvider,
) solace.RequestReplyMessageReceiver {
builder := messagingService.RequestReply().CreateRequestReplyMessageReceiverBuilder()
if len(configurationProviders) > 0 {
for _, configurationProvider := range configurationProviders {
builder.FromConfigurationProvider(configurationProvider)
}
}
receiver, err := builder.Build(subscription)
ExpectWithOffset(1, err).ToNot(HaveOccurred(), "Encountered error while building receiver")
return receiver
}

// StartRequestReplyMessageReceiverWithDefault function
func StartRequestReplyMessageReceiverWithDefault(
messagingService solace.MessagingService,
receiver solace.RequestReplyMessageReceiver,
) {

err := receiver.Start()
ExpectWithOffset(1, err).ToNot(HaveOccurred(), "Encountered error while starting receiver")
Expect(receiver.IsRunning()).To(BeTrue()) // running state should be true
messageHandler := func(message message.InboundMessage, replier solace.Replier) {
if replier == nil { // the replier is only set when received message is request message that would be replied to
return
}
builder := messagingService.MessageBuilder()
replyMsg, err := builder.BuildWithStringPayload("hello world reply")
ExpectWithOffset(1, err).ToNot(HaveOccurred())

replyErr := replier.Reply(replyMsg)
ExpectWithOffset(1, replyErr).ToNot(HaveOccurred())
}
// have receiver push request messages to request message handler
regErr := receiver.ReceiveAsync(messageHandler)
ExpectWithOffset(1, regErr).ToNot(HaveOccurred())
// return receiver
}
Loading
Loading