A package for very simplistic interaction with ActiveMQ REST API.
{ host : Host
, port_ : Port
, credentials : Credentials
, destination : Destination
}
A record carrying parameters for constructing a Configuration
.
A configuration needed to publish / consume, see configuration
.
configuration : ConfigParams -> Configuration
Constructs a Configuration
based in config params.
A tuple of user/password string pair.
defaultPort : Port
Default TCP port of the REST API of ActiveMQ installations, 8161.
JMS destinations are either queues or topics. Both type have a name.
Host of the ActiveMQ service.
TCP Port of the ActiveMQ REST API service, see defaultPort
.
The result of a publication attempt (can only convey success for now).
publishRequest : Configuration -> (Result Http.Error PublicationResult -> msg) -> Http.Body -> Platform.Cmd.Cmd msg
Given
a configuration,
a createMessage
function turning the result of a publication into a
message of your choice,
* an HTTP body you want to publish,
it constructs a POST request that will try to publish to ActiveMQ to configured destination.
consumeRequest : Configuration -> (Result ConsumptionError value -> msg) -> (String -> Result String value) -> Platform.Cmd.Cmd msg
Given
a configuration
a createMessage
function turning the result of a publication into a
message of your choice,
* a parser turning a response body into a result,
it constructs an HTTP GET request that will consume a message from configured destination. Success/failure responses will lead to a message of the type of your choice.
You cannot cancel this request right now, and it looks you should not, either: the little one-shot JMS consumer created for your request will be there, in the context of the REST API servlet within ActiveMQ service, for 30 seconds by default, even if you cancel the HTTP request ("servlet timeout"). That means certain loss of any message published between instant of canceling the HTTP request and that JMS consumer is being destroyed.
Do not use this call directly to organize a polling loop, since network failures and such will result in very busy polling indeed.
consumeRequestTask : Configuration -> (String -> Result String value) -> Task ConsumptionError value
Creates a task instead of a command, but otherwise similar to consumeRequest
.
You may want to use this version to implement correct message pollling loop with back-off strategy etc.
Most similar to Http.Error
, except there is a specific case for not having
any message to be consumed within the timeframe the call lasted (HTTP 204 No Content
).
urlOf : Configuration -> String
The URL of a Configuration
to be used by publish/consume requests.
authenticationOf : Configuration -> String
The authentication details of a Configuration
to be used by publish/consume requests.