use of com.microsoft.azure.storage.queue.CloudQueue in project camel by apache.
the class QueueServiceProducer method deleteQueue.
private void deleteQueue(Exchange exchange) throws Exception {
LOG.trace("Deleting the queue [{}] from exchange [{}]...", getConfiguration().getQueueName(), exchange);
CloudQueue client = QueueServiceUtil.createQueueClient(getConfiguration());
QueueServiceRequestOptions opts = QueueServiceUtil.getRequestOptions(exchange);
client.delete(opts.getRequestOpts(), opts.getOpContext());
}
use of com.microsoft.azure.storage.queue.CloudQueue in project camel by apache.
the class QueueServiceUtil method retrieveMessage.
public static void retrieveMessage(Exchange exchange, QueueServiceConfiguration cfg) throws Exception {
CloudQueue client = createQueueClient(cfg);
QueueServiceRequestOptions opts = getRequestOptions(exchange);
CloudQueueMessage message = client.retrieveMessage(cfg.getMessageVisibilityDelay(), opts.getRequestOpts(), opts.getOpContext());
ExchangeUtil.getMessageForResponse(exchange).setBody(message);
}
use of com.microsoft.azure.storage.queue.CloudQueue in project camel by apache.
the class QueueServiceComponentConfigurationTest method testCreateEndpointWithMinConfigForClientOnly.
@Test
public void testCreateEndpointWithMinConfigForClientOnly() throws Exception {
CloudQueue client = new CloudQueue(URI.create("https://camelazure.queue.core.windows.net/testqueue/messages"), newAccountKeyCredentials());
JndiRegistry registry = (JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry();
registry.bind("azureQueueClient", client);
QueueServiceComponent component = new QueueServiceComponent(context);
QueueServiceEndpoint endpoint = (QueueServiceEndpoint) component.createEndpoint("azure-queue://camelazure/testqueue?azureQueueClient=#azureQueueClient");
doTestCreateEndpointWithMinConfig(endpoint, true);
}
use of com.microsoft.azure.storage.queue.CloudQueue in project camel by apache.
the class QueueServiceUtilTest method testGetConfiguredClient.
@Test
public void testGetConfiguredClient() throws Exception {
CloudQueue client = new CloudQueue(URI.create("https://camelazure.queue.core.windows.net/testqueue/messages"), newAccountKeyCredentials());
JndiRegistry registry = (JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry();
registry.bind("azureQueueClient", client);
QueueServiceComponent component = new QueueServiceComponent(context);
QueueServiceEndpoint endpoint = (QueueServiceEndpoint) component.createEndpoint("azure-queue://camelazure/testqueue?azureQueueClient=#azureQueueClient");
assertSame(client, QueueServiceUtil.getConfiguredClient(endpoint.getConfiguration()));
}
use of com.microsoft.azure.storage.queue.CloudQueue in project wildfly-camel by wildfly-extras.
the class AzureIntegrationTest method testAppendQueue.
@Test
public void testAppendQueue() throws Exception {
StorageCredentials creds = getStorageCredentials("camelqueue", System.getenv(AZURE_STORAGE_QUEUE));
Assume.assumeNotNull("Credentials not null", creds);
OperationContext.setLoggingEnabledByDefault(true);
CamelContext camelctx = createCamelContext(creds);
camelctx.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
from("direct:createQueue").to("azure-queue://camelqueue/queue1?credentials=#creds&operation=createQueue");
from("direct:listQueues").to("azure-queue://camelqueue?credentials=#creds&operation=listQueues");
from("direct:deleteQueue").to("azure-queue://camelqueue/queue1?credentials=#creds&operation=deleteQueue");
from("direct:addMessage").to("azure-queue://camelqueue/queue1?credentials=#creds&operation=addMessage");
from("direct:retrieveMessage").to("azure-queue://camelqueue/queue1?credentials=#creds&operation=retrieveMessage");
}
});
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
Iterator<?> it = producer.requestBody("direct:listQueues", null, Iterable.class).iterator();
Assert.assertFalse("No more queues", it.hasNext());
producer.sendBody("direct:addMessage", "SomeMsg");
it = producer.requestBody("direct:listQueues", null, Iterable.class).iterator();
Assert.assertTrue("Has queues", it.hasNext());
CloudQueue queue = (CloudQueue) it.next();
Assert.assertEquals("queue1", queue.getName());
Assert.assertFalse("No more queues", it.hasNext());
try {
CloudQueueMessage msg = producer.requestBody("direct:retrieveMessage", null, CloudQueueMessage.class);
Assert.assertNotNull("Retrieve a message", msg);
Assert.assertEquals("SomeMsg", msg.getMessageContentAsString());
} finally {
queue.delete();
}
} finally {
camelctx.stop();
}
}
Aggregations