Skip to content

Commit 2ae9aec

Browse files
shibayanJatinSanghvi
authored andcommitted
Add dataType property to output / trigger annotation for Java (#219)
1 parent a46b8df commit 2ae9aec

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ The following attributes are common to both RabbitMQ trigger and output bindings
3838
| `ConnectionStringSetting` | string | The setting name for RabbitMQ connection URI. An example setting value would be `amqp://user:pass@host:10000/vhost`. |
3939
| `QueueName` | string | The RabbitMQ queue name. |
4040
| `DisableCertificateValidation` | boolean | Indicates whether certificate validation should be disabled. Not recommended for production. Does not apply when SSL is disabled. |
41+
| `dataType` | string | DataType of the message. "" by default as String, "binary" for byte[]|
4142

4243
## Further Reading
4344

java-library/src/main/java/com/microsoft/azure/functions/rabbitmq/annotation/RabbitMQOutput.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,14 @@
5555
* production. Does not apply when SSL is disabled.
5656
*/
5757
boolean disableCertificateValidation() default false;
58+
59+
/**
60+
* <p>Defines how Functions runtime should treat the parameter value. Possible values are:</p>
61+
* <ul>
62+
* <li>"" or string: treat it as a string whose value is serialized from the parameter</li>
63+
* <li>binary: treat it as a binary data whose value comes from for example OutputBinding&lt;byte[]&lt;</li>
64+
* </ul>
65+
* @return The dataType which will be used by the Functions runtime.
66+
*/
67+
String dataType() default "";
5868
}

java-library/src/main/java/com/microsoft/azure/functions/rabbitmq/annotation/RabbitMQTrigger.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,15 @@
5454
* production. Does not apply when SSL is disabled.
5555
*/
5656
boolean disableCertificateValidation() default false;
57+
58+
/**
59+
* <p>Defines how Functions runtime should treat the parameter value. Possible values are:</p>
60+
* <ul>
61+
* <li>"": get the value as a string, and try to deserialize to actual parameter type like POJO</li>
62+
* <li>string: always get the value as a string</li>
63+
* <li>binary: get the value as a binary data, and try to deserialize to actual parameter type byte[]</li>
64+
* </ul>
65+
* @return The dataType which will be used by the Functions runtime.
66+
*/
67+
String dataType() default "";
5768
}

java-library/src/test/java/com/microsoft/azure/functions/rabbitmq/annotation/RabbitMQOutputTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ public void TestRabbitMQOutput() {
1818
EasyMock.expect(outputMock.queueName()).andReturn("dummyQueueName");
1919
EasyMock.expect(outputMock.connectionStringSetting()).andReturn("dummyConnectionStringSetting");
2020
EasyMock.expect(outputMock.disableCertificateValidation()).andReturn(true);
21+
EasyMock.expect(outputMock.dataType()).andReturn("string");
2122
EasyMock.replay(outputMock);
2223

2324
Assert.assertEquals("dummyQueueName", outputMock.queueName());
2425
Assert.assertEquals("dummyConnectionStringSetting", outputMock.connectionStringSetting());
2526
Assert.assertEquals(true, outputMock.disableCertificateValidation());
27+
Assert.assertEquals("string", outputMock.dataType());
2628
}
2729
}

java-library/src/test/java/com/microsoft/azure/functions/rabbitmq/annotation/RabbitMQTriggerTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ public void TestRabbitMQTrigger() {
1818
EasyMock.expect(triggerMock.queueName()).andReturn("dummyQueueName");
1919
EasyMock.expect(triggerMock.connectionStringSetting()).andReturn("dummyConnectionStringSetting");
2020
EasyMock.expect(triggerMock.disableCertificateValidation()).andReturn(true);
21+
EasyMock.expect(triggerMock.dataType()).andReturn("string");
2122
EasyMock.replay(triggerMock);
2223

2324
Assert.assertEquals("dummyQueueName", triggerMock.queueName());
2425
Assert.assertEquals("dummyConnectionStringSetting", triggerMock.connectionStringSetting());
2526
Assert.assertEquals(true, triggerMock.disableCertificateValidation());
27+
Assert.assertEquals("string", triggerMock.dataType());
2628
}
2729
}

0 commit comments

Comments
 (0)