io.relayr

amqp

package amqp

Scala wrapper for interacting with AMQP, the aim is for convenient: - scala style usage - RPC calls - event hooks - reconnection strategies - message creation and extraction for common message types

Overview

Build connections with io.relayr.amqp.ConnectionHolder.builder

Create a connection:

val connection = ConnectionHolder.builder("amqps://guest:password@host:port")
.eventHooks(EventHooks(eventListener))
.reconnectionStrategy(ReconnectionStrategy.JavaClientFixedReconnectDelay(1 second))
.build()

Create a channel:

val channel = connection.newChannel()

Create an RPC server listening on queue "queue.name", expecting a String and echoing it back:

def rpcHandler(request: Message): Future[Message] = request match {
  case Message.String(string) => Future(Message.String(string))
}
val queue = QueueDeclare(Some("queue.name"))
val rpcServerCloser = channel.rpcServer(queue, AckOnHandled)(rpcHandler)

Create an RPC client method which sends requests to the queue "queue.name" with a response timeout of 10 seconds :

val rpcClient = RPCClient(channel)
val rpcMethod = rpcClient.newMethod(Exchange.Default.route("queue.name"), 10 second)

Create a consumer on "queue.name" printing out strings sent to it:

def consumer(request: Message): Unit = request match {
  case Message.String(string) => println(string)
}
val queue = QueueDeclare(Some("queue.name"))
channel.addConsumer(queue, consumer)

Send a message to "queue.name":

channel.send(Exchange.Default.route("queue.name"), Message.String("message")
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. amqp
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. class ByteArray extends Traversable[Byte]

    Wrapped immutable array of Bytes, produces a defensive copy of the passed array

  2. trait ChannelOwner extends AnyRef

    Operation to perform on an amqp channel, the underlying connection may fail and be replaced by a new one with the same parameters

  3. trait Closeable extends AnyRef

    Closeable for a handler of RPCs, close to stop the handler from being called

  4. trait ConnectionHolder extends AnyRef

    Holds a connection, the underlying connection may be replaced if it fails

  5. trait ConnectionHolderBuilder extends AnyRef

  6. sealed abstract class DeliveryMode extends AnyRef

  7. case class Envelope(exchange: String, routingKey: String, message: Message) extends Product with Serializable

    The message and any routing information that is included when it is received from a queue.

  8. sealed trait Event extends AnyRef

  9. trait EventHooks extends AnyRef

  10. case class Exchange(name: String) extends Product with Serializable

    Describes an exchange which should already exist, an error will be thrown on use if it does not

  11. abstract class ExchangeType extends AnyRef

  12. trait ManualAcker extends AnyRef

    Call to send Acks to Messages

  13. class Message extends AnyRef

    Message blob with content headers

  14. class MessageProperties extends AnyRef

  15. case class Publish(routingDescriptor: RoutingDescriptor, message: Message) extends Product with Serializable

  16. sealed trait Queue extends AnyRef

    Defines a queue to connect to or create

  17. case class QueueDeclare(name: Option[String], durable: Boolean = false, exclusive: Boolean = false, autoDelete: Boolean = true, args: Map[String, AnyRef] = ...) extends Queue with Product with Serializable

    Parameters to create a new queue

  18. case class QueuePassive(name: String) extends Queue with Product with Serializable

    Describes an exchange which should already exist, an error is thrown if it does not

  19. trait RPCClient extends AnyRef

  20. trait RPCMethod extends (Message) ⇒ Future[Message]

    RPC method over AMQP.

  21. sealed trait ReconnectionStrategy extends AnyRef

  22. case class RoutingDescriptor(exchange: Exchange, routingKey: String, deliveryMode: Option[DeliveryMode], mandatory: Boolean, immediate: Boolean) extends Product with Serializable

    Specifies routing and send parameters

  23. sealed trait RpcServerAutoAckMode extends AnyRef

  24. trait ToMessage[-T] extends AnyRef

  25. case class UndeliveredException() extends Exception with Product with Serializable

    The queue server found nowhere to route the message

Value Members

  1. object ByteArray

    Produces an immutable array of bytes

  2. object ConnectionHolder

    Create a connection using the builder:

  3. object DeliveryMode

    DeliveryMode is a header on AMQP messages.

  4. object Event

  5. object EventHooks

    Some basic strategies for handling events

  6. object Exchange extends Serializable

  7. object ExchangeType

  8. object Message

    Message blob with content headers, usually you would use the child objects to construct / extract different types of messages

  9. object MessageProperties

  10. object RPCClient

  11. object ReconnectionStrategy

    Strategies for reconnection, currently only fixed delay or no reconnection are available

  12. object RpcServerAutoAckMode

    Some options for when the server will Ack the request message, clients only have the AckOnReceive auto Ack strategy

  13. package concurrent

  14. package connection

  15. package properties

  16. package rpc

Inherited from AnyRef

Inherited from Any

Ungrouped