Skip to content

Use in wildfly #24

@a-ferrari

Description

@a-ferrari

Thanks for your code
I use it in my j2ee application in Wildfly 10 I did few changes the most important is close the response after using it ( otherwise this exception is thrown 'Caused by: java.lang.IllegalStateException: Invalid use of BasicClientConnManager: connection still allocated.
Make sure to release the connection before allocating another one.' )

My snippet of WnsClient push method

	Response response = webResourceBuilder
			.buildPost(Entity.entity(resourceBuilder.getEntityToSendWithNotification(notification), type)).invoke();
	WnsNotificationResponse notificationResponse = null;
	try {
		notificationResponse = new WnsNotificationResponse(channelUri, response.getStatus(),
				response.getStringHeaders());
		if (notificationResponse.code == 200) {
			return notificationResponse;
		}

		if (notificationResponse.code == 401 && retriesLeft > 0) {
			retriesLeft--;
			// Access token may have expired
			refreshAccessToken();
			// Retry
			return this.push(resourceBuilder, channelUri, notification, retriesLeft, optional);
		}
	} finally {
		if (response != null) {
			// EntityUtils.consume((HttpEntity) response.getEntity());
			//EntityUtils.consumeQuietly((HttpEntity) response.getEntity());
			response.close();
		}
	}

best regards
Alberto

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions