class AmqpClient extends AnyRef
An AMQP client simplifying some of the common interactions with AMQP brokers. It handles correctly cases in which the broker is not reachable at the time operations are done, waiting for a connection to be established first.
- Alphabetic
- By Inheritance
- AmqpClient
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- implicit val actorRefFactory: ActorRefFactory
-
def
addConsumer(actor: ActorRef, exchangeName: String, routingKey: String, queueName: Option[String] = None, autodelete: Boolean = true, handlerActor: Option[ActorRef] = None, clientFacing: Boolean = false): Future[String]
Declares a queue, binds it to an exchange and routing key and adds a consumer to it.
Declares a queue, binds it to an exchange and routing key and adds a consumer to it.
- actor
the actor which will consume com.github.sstone.amqp.Amqp.Delivery messages
- exchangeName
the exchange name
- routingKey
the routing key
- queueName
the underlying queue name wrapped in a
Some, orNoneto generate one with a random suffix- autodelete
trueif the queue should be destroyed when it is no longer used,falseotherwise- handlerActor
the actor to handle the channel state; it can receive the messages com.github.sstone.amqp.ChannelOwner.Disconnected, com.github.sstone.amqp.ChannelOwner.Connected and com.github.sstone.amqp.Amqp.Error
- clientFacing
trueif the queue will be read by an AdStax-external client,falseotherwise- returns
a
Futurethat is completed with the queue name when the consumer is successfully added.
-
def
addConsumerWithBindingActor(actor: ActorRef, exchangeName: String, routingKey: String, queueName: Option[String] = None, autodelete: Boolean = true, handlerActor: Option[ActorRef] = None, clientFacing: Boolean = false): Future[(ActorRef, String)]
Declares a queue, binds it to an exchange and routing key and adds a consumer to it.
Declares a queue, binds it to an exchange and routing key and adds a consumer to it. Returns additionally the underlying actor doing the binding, which can be killed later to stop the consumption of AMQP messages.
- actor
the actor which will consume com.github.sstone.amqp.Amqp.Delivery messages
- exchangeName
the exchange name
- routingKey
the routing key
- queueName
the underlying queue name wrapped in a
Some, orNoneto generate one with a random suffix- autodelete
trueif the queue should be destroyed when it is no longer used,falseotherwise- handlerActor
the actor to handle the channel state; it can receive the messages com.github.sstone.amqp.ChannelOwner.Disconnected, com.github.sstone.amqp.ChannelOwner.Connected and com.github.sstone.amqp.Amqp.Error
- clientFacing
trueif the queue will be read by an AdStax-external client,falseotherwise- returns
a
Futurethat is completed with the underlying binding actor and the queue name when the consumer is successfully added.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
- val connFactory: ConnectionFactory
-
def
createProducer(handlerActor: Option[ActorRef]): ActorRef
Creates a producer actor.
Creates a producer actor. Producer actors can be sent com.github.sstone.amqp.Amqp.Publish, which they dispatch to the AMQP broker. The created actor will discard publish messages that are sent at a time in which the client is disconnected from the broker.
- handlerActor
the actor to handle the channel state; it can receive the messages com.github.sstone.amqp.ChannelOwner.Disconnected, com.github.sstone.amqp.ChannelOwner.Connected and com.github.sstone.amqp.Amqp.Error
- returns
the
ActorRefof the producer.
-
def
createRpcClient(handlerActor: Option[ActorRef] = None): Future[ActorRef]
Creates an RPC client.
Creates an RPC client.
- handlerActor
the actor to handle the channel state; it can receive the messages com.github.sstone.amqp.ChannelOwner.Disconnected, com.github.sstone.amqp.ChannelOwner.Connected and com.github.sstone.amqp.Amqp.Error
- returns
a
Futurethat is completed with the RPC producer actor when it is successfully bound.
-
def
createRpcServer(exchangeName: String, routingKey: String, queueName: Option[String] = None, handlerActor: Option[ActorRef] = None, timeout: Option[FiniteDuration] = None)(processFunc: (Delivery) ⇒ Future[ProcessResult]): Future[String]
Sets up an RPC server.
Sets up an RPC server. The server starts processing incoming messages sent to an exchange and routing key and replies to them according to a given behavior.
The queue name can be
Noneto create a One-To-Many (all servers/processors handle the request) or specified for a One-To-Any (only one server/processor will handle the request).- exchangeName
the exchange name
- routingKey
the routing key
- queueName
the underlying queue name wrapped in a
Somefor One-To-Any behavior, orNoneto generate one with a random suffix for One-To-Many behavior- handlerActor
the actor to handle the channel state; it can receive the messages com.github.sstone.amqp.ChannelOwner.Disconnected, com.github.sstone.amqp.ChannelOwner.Connected and com.github.sstone.amqp.Amqp.Error
- timeout
an optional message timeout to avoid filling up the queue with old, already ignored, responses
- processFunc
the function that processes
Deliverymessages and returns the reply for each one of them- returns
a
Futurethat is completed with the queue name when the server is started.
-
def
createStashedProducer(): ActorRef
Creates a producer actor which stashes messages until the producer is fully connected to the AMQP broker.
Creates a producer actor which stashes messages until the producer is fully connected to the AMQP broker. Producer actors can be sent com.github.sstone.amqp.Amqp.Publish, which they dispatch to the AMQP broker.
- returns
the
ActorRefof the producer.
-
def
declareExchange(exchangeName: String, exchangeType: String = "topic", handlerActor: Option[ActorRef] = None): Future[Unit]
Declares an exchange.
Declares an exchange.
- exchangeName
the exchange name
- exchangeType
the exchange type
- handlerActor
the actor to handle the channel state; it can receive the messages com.github.sstone.amqp.ChannelOwner.Disconnected, com.github.sstone.amqp.ChannelOwner.Connected and com.github.sstone.amqp.Amqp.Error
- returns
a
Futurethat is completed when the exchange is successfully declared.
-
def
declareQueue(exchangeName: String, routingKey: String, queueName: Option[String] = None, autodelete: Boolean = true, handlerActor: Option[ActorRef] = None, clientFacing: Boolean = false): Future[String]
Declares a queue and binds it to an exchange and routing key.
Declares a queue and binds it to an exchange and routing key.
- exchangeName
the exchange name to bind the queue to
- routingKey
the routing key to bind the queue to
- queueName
the queue name wrapped in a
Some, orNoneto generate one with a random suffix- autodelete
trueif the queue should be destroyed when it is no longer used,falseotherwise- handlerActor
the actor to handle the channel state; it can receive the messages com.github.sstone.amqp.ChannelOwner.Disconnected, com.github.sstone.amqp.ChannelOwner.Connected and com.github.sstone.amqp.Amqp.Error
- clientFacing
trueif the queue will be read by an AdStax-external client,falseotherwise- returns
a
Futurethat is completed with the queue name when the queue is successfully bound.
-
implicit
def
dispatcher: ExecutionContextExecutor
The
ExecutionContextused by this client to schedule asynchronous tasks. -
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )