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

AMQP: Fixes handling null replyTo header in AmqpReplyToSinkStage #2371

Merged
merged 1 commit into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private[amqp] final class AmqpReplyToSinkStage(settings: AmqpReplyToSinkSettings
override def onPush(): Unit = {
val elem = grab(in)

val replyTo = elem.properties.map(_.getReplyTo)
val replyTo = elem.properties.flatMap(properties => Option(properties.getReplyTo))

if (replyTo.isDefined) {
channel.basicPublish(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import akka.stream.testkit.scaladsl.TestSink
import akka.stream.testkit.scaladsl.StreamTestKit.assertAllStagesStopped
import akka.stream.testkit.{TestPublisher, TestSubscriber}
import akka.util.ByteString
import com.rabbitmq.client.AMQP.BasicProperties
import com.rabbitmq.client.AuthenticationFailureException

import scala.concurrent.Await
Expand Down Expand Up @@ -146,6 +147,21 @@ class AmqpConnectorsSpec extends AmqpSpec {

caught.getCause.getMessage should equal("Reply-to header was not set")

val propertiesWithNullReplyTo = new BasicProperties()
.builder()
.appId("appId")
.build()
val outgoingMessageWithEmptyReplyTo = outgoingMessage
.withProperties(propertiesWithNullReplyTo)

Source
.single(outgoingMessageWithEmptyReplyTo)
.toMat(AmqpSink.replyTo(AmqpReplyToSinkSettings(connectionProvider).withFailIfReplyToMissing(false)))(
Keep.right
)
.run()
.futureValue shouldBe Done

}

"publish from one source and consume elements with multiple sinks" in assertAllStagesStopped {
Expand Down