Packages

  • package root
    Definition Classes
    root
  • package io
    Definition Classes
    root
  • package leonard
    Definition Classes
    io
  • 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

    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.leonard.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")
    Definition Classes
    leonard
  • package concurrent
  • package connection
  • package properties
  • package rpc
  • ByteArray
  • ChannelOwner
  • Closeable
  • ConnectionHolder
  • ConnectionHolderBuilder
  • DeliveryMode
  • Envelope
  • Event
  • EventHooks
  • Exchange
  • ExchangeType
  • ManualAcker
  • Message
  • MessageProperties
  • Publish
  • Queue
  • QueueDeclare
  • QueuePassive
  • RPCClient
  • RPCMethod
  • ReconnectionStrategy
  • RoutingDescriptor
  • RpcServerAutoAckMode
  • ToMessage
  • UndeliveredException

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.leonard.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
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

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

    It is recommended to use ChannelOwner.declareExchange or ChannelOwner.declareExchangePassive to create this as they ensures the exchange exists.

  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] = Map.empty) 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.

    RPC method over AMQP.

    The future either completes with the correlating response message, an RPCTimeout or UndeliveredException

    Annotations
    @throws( ... ) @throws( ... )
  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

    Specifies routing and send parameters

    exchange

    for the message to be sent to

    routingKey

    the exchange uses this to decide which queue(s) the message is to be added to

    deliveryMode

    defines whether a message should be persisted if the queue it is on is persisted

    mandatory

    a message with this flag will be returned by the exchange if it finds that no queues match the routingKey

    immediate

    a message with this flag will only be delivered if a matching queue has a ready consumer, if not it is returned

  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:

    Create a connection using the builder:

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

    DeliveryMode is a header on AMQP messages.

    DeliveryMode is a header on AMQP messages. It ONLY has an effect on messages which arrive at DURABLE queues.

    DURABLE queues are ones which are persistent themselves - they are recreated after a broker restart.

    Persistent messages on DURABLE queues are also written to disk and will be recovered after a broker restart.

  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

Inherited from AnyRef

Inherited from Any

Ungrouped