parent
d04baed38b
commit
ebc4570941
|
@ -25,6 +25,7 @@ import org.apache.http.conn.ssl.DefaultHostnameVerifier;
|
||||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||||
import org.bouncycastle.openssl.PEMReader;
|
import org.bouncycastle.openssl.PEMReader;
|
||||||
import org.glassfish.jersey.client.ClientProperties;
|
import org.glassfish.jersey.client.ClientProperties;
|
||||||
|
import org.glassfish.jersey.client.RequestEntityProcessing;
|
||||||
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
|
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -168,10 +169,13 @@ public class FederatedClient {
|
||||||
public void sendMessages(String source, long sourceDeviceId, String destination, IncomingMessageList messages)
|
public void sendMessages(String source, long sourceDeviceId, String destination, IncomingMessageList messages)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
Response response = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Response response = client.target(peer.getUrl())
|
response = client.target(peer.getUrl())
|
||||||
.path(String.format(RELAY_MESSAGE_PATH, source, sourceDeviceId, destination))
|
.path(String.format(RELAY_MESSAGE_PATH, source, sourceDeviceId, destination))
|
||||||
.request()
|
.request()
|
||||||
|
.property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.BUFFERED)
|
||||||
.put(Entity.entity(messages, MediaType.APPLICATION_JSON_TYPE));
|
.put(Entity.entity(messages, MediaType.APPLICATION_JSON_TYPE));
|
||||||
|
|
||||||
if (response.getStatus() != 200 && response.getStatus() != 204) {
|
if (response.getStatus() != 200 && response.getStatus() != 204) {
|
||||||
|
@ -181,14 +185,18 @@ public class FederatedClient {
|
||||||
} catch (ProcessingException e) {
|
} catch (ProcessingException e) {
|
||||||
logger.warn("sendMessage", e);
|
logger.warn("sendMessage", e);
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
|
} finally {
|
||||||
|
if (response != null) response.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendDeliveryReceipt(String source, long sourceDeviceId, String destination, long messageId)
|
public void sendDeliveryReceipt(String source, long sourceDeviceId, String destination, long messageId)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
Response response = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Response response = client.target(peer.getUrl())
|
response = client.target(peer.getUrl())
|
||||||
.path(String.format(RECEIPT_PATH, source, sourceDeviceId, destination, messageId))
|
.path(String.format(RECEIPT_PATH, source, sourceDeviceId, destination, messageId))
|
||||||
.request()
|
.request()
|
||||||
.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true)
|
.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true)
|
||||||
|
@ -200,6 +208,8 @@ public class FederatedClient {
|
||||||
} catch (ProcessingException e) {
|
} catch (ProcessingException e) {
|
||||||
logger.warn("sendMessage", e);
|
logger.warn("sendMessage", e);
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
|
} finally {
|
||||||
|
if (response != null) response.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue