Search in sources :

Example 6 with TAzureStorageQueueOutputProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeueoutput.TAzureStorageQueueOutputProperties in project components by Talend.

the class AzureStorageQueueOutputWriterTestIT method testWriteTTLMessage.

@Test
public void testWriteTTLMessage() throws Throwable {
    queue.clear();
    // 
    TAzureStorageQueueOutputProperties properties = new TAzureStorageQueueOutputProperties("tests");
    properties = (TAzureStorageQueueOutputProperties) setupConnectionProperties((AzureStorageProvideConnectionProperties) properties);
    properties.setupProperties();
    properties.queueName.setValue(TEST_QUEUE_NAME);
    properties.timeToLiveInSeconds.setValue(5);
    Writer<?> writer = createWriter(properties);
    writer.open("test-uid");
    for (String m : messages) {
        IndexedRecord entity = new GenericData.Record(properties.schema.schema.getValue());
        entity.put(0, m + "TTL");
        writer.write(entity);
    }
    writer.close();
    int msgCount = 0;
    for (CloudQueueMessage msg : queue.retrieveMessages(30)) {
        msgCount++;
        assertNotNull(msg.getMessageContentAsString());
        assertTrue(msg.getMessageContentAsString().indexOf("TTL") > 0);
    }
    assertEquals(3, msgCount);
    Thread.sleep(5000);
    msgCount = 0;
    for (CloudQueueMessage msg : queue.retrieveMessages(30)) {
        msgCount++;
        assertNotNull(msg.getMessageContentAsString());
    }
    assertEquals(0, msgCount);
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) CloudQueueMessage(com.microsoft.azure.storage.queue.CloudQueueMessage) TAzureStorageQueueOutputProperties(org.talend.components.azurestorage.queue.tazurestoragequeueoutput.TAzureStorageQueueOutputProperties) IndexedRecord(org.apache.avro.generic.IndexedRecord) Test(org.junit.Test)

Example 7 with TAzureStorageQueueOutputProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeueoutput.TAzureStorageQueueOutputProperties in project components by Talend.

the class AzureStorageQueueOutputWriterTestIT method testWriteDelayedMessage.

@Test
public void testWriteDelayedMessage() throws Throwable {
    queue.clear();
    // 
    TAzureStorageQueueOutputProperties properties = new TAzureStorageQueueOutputProperties("tests");
    properties = (TAzureStorageQueueOutputProperties) setupConnectionProperties((AzureStorageProvideConnectionProperties) properties);
    properties.setupProperties();
    properties.queueName.setValue(TEST_QUEUE_NAME);
    properties.initialVisibilityDelayInSeconds.setValue(5);
    Writer<?> writer = createWriter(properties);
    writer.open("test-uid");
    for (String m : messages) {
        IndexedRecord entity = new GenericData.Record(properties.schema.schema.getValue());
        entity.put(0, m + "DLY");
        writer.write(entity);
    }
    writer.close();
    int msgCount = 0;
    for (CloudQueueMessage msg : queue.retrieveMessages(30)) {
        // we shoud not be here ...
        msgCount++;
        assertNotNull(msg.getMessageContentAsString());
        assertTrue(msg.getMessageContentAsString().indexOf("DLY") > 0);
    }
    assertEquals(0, msgCount);
    Thread.sleep(5000);
    msgCount = 0;
    for (CloudQueueMessage msg : queue.retrieveMessages(30)) {
        msgCount++;
        assertNotNull(msg.getMessageContentAsString());
        assertTrue(msg.getMessageContentAsString().indexOf("DLY") > 0);
    }
    assertEquals(3, msgCount);
    queue.downloadAttributes();
    assertEquals(3, queue.getApproximateMessageCount());
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) CloudQueueMessage(com.microsoft.azure.storage.queue.CloudQueueMessage) TAzureStorageQueueOutputProperties(org.talend.components.azurestorage.queue.tazurestoragequeueoutput.TAzureStorageQueueOutputProperties) IndexedRecord(org.apache.avro.generic.IndexedRecord) Test(org.junit.Test)

Aggregations

TAzureStorageQueueOutputProperties (org.talend.components.azurestorage.queue.tazurestoragequeueoutput.TAzureStorageQueueOutputProperties)7 Test (org.junit.Test)5 IndexedRecord (org.apache.avro.generic.IndexedRecord)4 CloudQueueMessage (com.microsoft.azure.storage.queue.CloudQueueMessage)3 Before (org.junit.Before)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 PropertyPathConnector (org.talend.components.api.component.PropertyPathConnector)1 Result (org.talend.components.api.component.runtime.Result)1 AzureStorageQueueSink (org.talend.components.azurestorage.queue.runtime.AzureStorageQueueSink)1