public class RestClient extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
RestClient.Type |
| Constructor and Description |
|---|
RestClient(String host,
Integer port)
Creates the sender with a default HTTP endpoint of the REST server.
|
RestClient(String protocol,
String host,
Integer port)
Creates the sender with a default endpoint of the REST server.
|
RestClient(URL endpoint)
Endpoint of the REST server, not including the fragment that consists of the queue/topic name.
|
| Modifier and Type | Method and Description |
|---|---|
protected URL |
appendToURL(URL url,
String appendage) |
URL |
getEndpoint() |
protected URL |
getEndpointForType(RestClient.Type type,
String name) |
protected org.apache.http.HttpResponse |
postMessage(RestClient.Type type,
String name,
String jsonPayload,
Map<String,String> headers) |
org.apache.http.HttpResponse |
postQueueMessage(String queueName,
String jsonPayload,
Map<String,String> headers)
Sends a message to the REST endpoint in order to put a message on the given queue.
|
org.apache.http.HttpResponse |
postTopicMessage(String topicName,
String jsonPayload,
Map<String,String> headers)
Sends a message to the REST endpoint in order to put a message on the given topic.
|
protected org.apache.http.HttpResponse |
sendPost(URI uri,
String jsonPayload,
Map<String,String> headers) |
public RestClient(String host, Integer port) throws RestClientException
host - the remote serverport - if null or -1, no port will be specified in the URLRestClientException - if the endpoint cannot be used to refer to queues or topics
or if one of the parameters consists of invalid URL syntaxpublic RestClient(String protocol, String host, Integer port) throws RestClientException
protocol - http or httpshost - the remote serverport - if null or -1, no port will be specified in the URLRestClientException - if the endpoint cannot be used to refer to queues or topics
or if one of the parameters consists of invalid URL syntaxpublic RestClient(URL endpoint) throws RestClientException
endpoint - the REST server endpoint, not including the queue/topic nameRestClientException - if the endpoint cannot be used to refer to queues or topicspublic URL getEndpoint()
public org.apache.http.HttpResponse postTopicMessage(String topicName, String jsonPayload, Map<String,String> headers) throws RestClientException
topicName - name of the topicjsonPayload - the actual message (as a JSON string) to put on the busheaders - any headers to send with the message (can be null or empty)RestClientException - if the response was not a 200 status codepublic org.apache.http.HttpResponse postQueueMessage(String queueName, String jsonPayload, Map<String,String> headers) throws RestClientException
queueName - name of the queuejsonPayload - the actual message (as a JSON string) to put on the busheaders - any headers to send with the message (can be null or empty)RestClientException - if the response was not a 200 status codeprotected org.apache.http.HttpResponse postMessage(RestClient.Type type, String name, String jsonPayload, Map<String,String> headers) throws RestClientException
RestClientExceptionprotected org.apache.http.HttpResponse sendPost(URI uri, String jsonPayload, Map<String,String> headers) throws RestClientException
RestClientExceptionprotected URL getEndpointForType(RestClient.Type type, String name) throws RestClientException
RestClientExceptionprotected URL appendToURL(URL url, String appendage) throws RestClientException
RestClientExceptionCopyright © 2015 Red Hat, Inc.. All rights reserved.