-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathShmoopySoftConfluentKafkaMessageExample.bprelease
85 lines (81 loc) · 20.1 KB
/
ShmoopySoftConfluentKafkaMessageExample.bprelease
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?xml version="1.0" encoding="utf-8"?>
<bpr:release xmlns:bpr="http://www.blueprism.co.uk/product/release">
<bpr:name>ShmoopySoftConfluentKafkaMessageExample</bpr:name>
<bpr:release-notes />
<bpr:created>2020-03-04 16:17:52Z</bpr:created>
<bpr:package-id>7</bpr:package-id>
<bpr:package-name>ShmoopySoft Confluent Kafka Message Example</bpr:package-name>
<bpr:user-created-by>admin</bpr:user-created-by>
<bpr:contents count="4">
<process id="b6e9b7ab-4ced-4a50-99a2-94d4e7664183" name="Confluent Kafka Process" xmlns="http://www.blueprism.co.uk/product/process"><process name="Confluent Kafka Process" version="1.0" bpversion="6.4.2.10610" narrative="Sends messages to Confluent Kafka using the Confluent.Kafka open source library for .NET." byrefcollection="true"><view><camerax>-68</camerax><cameray>-53</cameray><zoom version="2">0.9375</zoom></view><preconditions /><endpoint narrative="" /><stage stageid="0aac4aad-bef5-45f8-b2a2-afac03a79c64" name="Stage1" type="ProcessInfo"><loginhibit onsuccess="true" /><narrative></narrative><displayx>-270</displayx><displayy>-105</displayy><displaywidth>330</displaywidth><displayheight>90</displayheight><font family="Arial" size="12" style="Regular" color="000000" /></stage><stage stageid="7dc4d2b0-12ef-488b-8fe3-32de2a45281e" name="Start" type="Start"><loginhibit onsuccess="true" /><narrative></narrative><displayx>15</displayx><displayy>-135</displayy><displaywidth>60</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><onsuccess>7cf43b23-707d-4878-af6f-2216143fbd10</onsuccess></stage><stage stageid="e4be280d-f26c-41ce-8531-32bc7de753b0" name="End" type="End"><loginhibit onsuccess="true" /><narrative></narrative><displayx>15</displayx><displayy>105</displayy><displaywidth>60</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /></stage><stage stageid="7cf43b23-707d-4878-af6f-2216143fbd10" name="Send Kafka Message" type="Action"><loginhibit onsuccess="true" /><narrative></narrative><displayx>15</displayx><displayy>-60</displayy><displaywidth>120</displaywidth><displayheight>60</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><inputs><input type="text" name="MessageText" narrative="The message text to send." expr="[vMessageText]" /><input type="text" name="KafkaTopic" narrative="The Kafka topic to send the message to." expr="[vKafkaTopic]" /></inputs><outputs><output type="flag" name="Success" narrative="True if the message was sent." stage="vSuccess" /><output type="text" name="Message" narrative="The message returned by the Code Stage." stage="vMessage" /></outputs><onsuccess>cad59364-a816-4987-89ea-265c55da68d5</onsuccess><resource object="Confluent Kafka" action="Send Kafka Message" /></stage><stage stageid="a8549428-0820-4b42-925a-f2012d9c3fde" name="Protected (Private) Data Items" type="Block"><loginhibit onsuccess="true" /><narrative></narrative><displayx>-435</displayx><displayy>-30</displayy><displaywidth>330</displaywidth><displayheight>120</displayheight><font family="Arial" size="12" style="Regular" color="99CCFF" /></stage><stage stageid="b309ecfd-8823-4d0a-8b94-af63d051ae9a" name="vMessageText" type="Data"><loginhibit onsuccess="true" /><narrative>The message you want to send (URL-encoded).</narrative><displayx>-270</displayx><displayy>15</displayy><displaywidth>300</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>text</datatype><initialvalue xml:space="preserve">This message was sent from Blue Prism :-)</initialvalue><private /><alwaysinit /></stage><stage stageid="cad59364-a816-4987-89ea-265c55da68d5" name="Message Sent?" type="Decision"><loginhibit onsuccess="true" /><narrative></narrative><displayx>15</displayx><displayy>30</displayy><displaywidth>90</displaywidth><displayheight>60</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><decision expression="[vSuccess]" /><ontrue>e4be280d-f26c-41ce-8531-32bc7de753b0</ontrue><onfalse>90a9c807-4187-4dae-ad28-60def83a7076</onfalse></stage><stage stageid="90a9c807-4187-4dae-ad28-60def83a7076" name="Send Kafka Message Exception" type="Exception"><loginhibit onsuccess="true" /><narrative></narrative><displayx>135</displayx><displayy>30</displayy><displaywidth>90</displaywidth><displayheight>60</displayheight><font family="Arial" size="12" style="Bold" color="FF0000" /><exception type="System Exception" detail="[vMessage]" /></stage><stage stageid="aab18812-1cda-472c-b703-8a4b32f9e739" name="Note1" type="Note"><loginhibit onsuccess="true" /><narrative>[vMessageText] is the message you want to send
[vTopicName] is the Kafka topic name to send the message to</narrative><displayx>-90</displayx><displayy>-210</displayy><displaywidth>720</displaywidth><displayheight>60</displayheight><font family="Arial" size="15" style="Regular" color="0000FF" /></stage><stage stageid="69a9f2f7-4f9d-451f-8fc0-5d2af50bd6cf" name="Action Return Values" type="Block"><loginhibit onsuccess="true" /><narrative></narrative><displayx>-435</displayx><displayy>120</displayy><displaywidth>330</displaywidth><displayheight>75</displayheight><font family="Arial" size="12" style="Regular" color="339966" /></stage><stage stageid="79609f68-8f8c-4260-ba59-f35213ebe803" name="vSuccess" type="Data"><loginhibit onsuccess="true" /><narrative>True if sending the message was successful.</narrative><displayx>-195</displayx><displayy>165</displayy><displaywidth>150</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>flag</datatype><initialvalue /><private /><alwaysinit /></stage><stage stageid="a0af25d1-c929-4b05-b726-509cf360884d" name="vMessage" type="Data"><loginhibit onsuccess="true" /><narrative>The message returned by the Syslog action.</narrative><displayx>-345</displayx><displayy>165</displayy><displaywidth>150</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>text</datatype><initialvalue /><private /><alwaysinit /></stage><stage stageid="ead5ee11-5433-485d-922b-8447fb036c99" name="vKafkaTopic" type="Data"><loginhibit onsuccess="true" /><narrative>The Kafka topic name to send the message to.</narrative><displayx>-270</displayx><displayy>60</displayy><displaywidth>300</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>text</datatype><initialvalue xml:space="preserve">My-Kafka-Topic</initialvalue><private /><alwaysinit /></stage><stage stageid="0abb9f4c-7bc1-47f1-b829-a32e944f582d" name="Note1" type="Note"><loginhibit onsuccess="true" /><narrative>ShmoopySoft Blue Prism Confluent Kafka Message Example</narrative><displayx>-90</displayx><displayy>-270</displayy><displaywidth>720</displaywidth><displayheight>30</displayheight><font family="Arial" size="20" style="Bold" color="000000" /></stage></process></process>
<object id="88a61f0c-a520-417f-92e6-ce4dbf5065fa" name="Confluent Kafka" xmlns="http://www.blueprism.co.uk/product/process"><process name="Confluent Kafka" version="1.0" bpversion="6.4.2.10610" narrative="A business object that sends messages to Confluent Kafka using the Confluent.Kafka open source library for .NET.

This object is set to run in BACKGROUND MODE." byrefcollection="true" type="object" runmode="Background"><appdef><element name="Application Root"><id>78994528-1ebf-4794-a001-a51dd37ea03b</id><type>Application</type><basetype>Application</basetype><datatype>unknown</datatype><diagnose>False</diagnose></element></appdef><view><camerax>-105</camerax><cameray>0</cameray><zoom version="2">0.9375</zoom></view><preconditions><condition narrative="The Confluent.Kafka client library for .NET must be installed in: C:\Program Files\Blue Prism Limited\Blue Prism Automate\Confluent.Kafka.dll" /></preconditions><endpoint narrative="" /><subsheet subsheetid="819f1fed-9231-4892-9e5d-cc545c817aae" type="CleanUp" published="True"><name>Clean Up</name><view><camerax>0</camerax><cameray>0</cameray><zoom version="2">0.9375</zoom></view></subsheet><subsheet subsheetid="9bd403e8-ee47-4931-a361-58127a529ee1" type="Normal" published="True"><name>Send Kafka Message</name><view><camerax>-145</camerax><cameray>14</cameray><zoom version="2">0.9375</zoom></view></subsheet><stage stageid="2cf738f4-34ec-4f24-8005-abe46c51ed13" name="Start" type="Start"><loginhibit /><narrative></narrative><displayx>15</displayx><displayy>-105</displayy><displaywidth>60</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><onsuccess>be064e34-4196-41de-a255-428f8f695cce</onsuccess></stage><stage stageid="be064e34-4196-41de-a255-428f8f695cce" name="End" type="End"><loginhibit /><narrative></narrative><displayx>15</displayx><displayy>90</displayy><displaywidth>60</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /></stage><stage stageid="2fd03054-631f-4af2-bd38-b5e099fc9ff4" name="Stage1" type="ProcessInfo"><loginhibit /><narrative></narrative><displayx>-225</displayx><displayy>-75</displayy><displaywidth>330</displaywidth><displayheight>90</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><references><reference>System.dll</reference><reference>System.Data.dll</reference><reference>System.Xml.dll</reference><reference>System.Drawing.dll</reference><reference>C:\Program Files\Blue Prism Limited\Blue Prism Automate\Confluent.Kafka.dll</reference></references><imports><import>System</import><import>System.Drawing</import><import>System.Data</import><import>Confluent.Kafka</import></imports><language>csharp</language><globalcode><![CDATA[]]></globalcode><code><![CDATA[]]></code></stage><stage stageid="39fa5ca6-6f19-4348-9f55-4326c3d2bbd3" name="Clean Up" type="SubSheetInfo"><subsheetid>819f1fed-9231-4892-9e5d-cc545c817aae</subsheetid><loginhibit /><narrative></narrative><displayx>-135</displayx><displayy>-75</displayy><displaywidth>150</displaywidth><displayheight>90</displayheight><font family="Arial" size="12" style="Regular" color="000000" /></stage><stage stageid="0c1bb4ac-135a-4e11-8fe6-d8560f3a4039" name="Start" type="Start"><subsheetid>819f1fed-9231-4892-9e5d-cc545c817aae</subsheetid><loginhibit /><narrative></narrative><displayx>15</displayx><displayy>-105</displayy><displaywidth>60</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><onsuccess>06743f9b-64cd-41ef-bd9f-429d7a36c58b</onsuccess></stage><stage stageid="06743f9b-64cd-41ef-bd9f-429d7a36c58b" name="End" type="End"><subsheetid>819f1fed-9231-4892-9e5d-cc545c817aae</subsheetid><loginhibit /><narrative></narrative><displayx>15</displayx><displayy>90</displayy><displaywidth>60</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /></stage><stage stageid="e1a4784f-d906-4b85-bc0b-a9bff18888a1" name="Send Kafka Message" type="SubSheetInfo"><subsheetid>9bd403e8-ee47-4931-a361-58127a529ee1</subsheetid><loginhibit /><narrative>Sends a message to Confluent Kafka.</narrative><displayx>-255</displayx><displayy>-105</displayy><displaywidth>330</displaywidth><displayheight>90</displayheight><font family="Arial" size="12" style="Regular" color="000000" /></stage><stage stageid="f116fcbc-d246-4f7c-8208-817684f898e2" name="Start" type="Start"><subsheetid>9bd403e8-ee47-4931-a361-58127a529ee1</subsheetid><loginhibit /><preconditions><condition narrative="The Confluent.Kafka client library for .NET must be installed in: C:\Program Files\Blue Prism Limited\Blue Prism Automate\Confluent.Kafka.dll" /></preconditions><narrative></narrative><displayx>15</displayx><displayy>-135</displayy><displaywidth>60</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><inputs><input type="text" name="MessageText" narrative="The message text to send." stage="inMessageText" /><input type="text" name="KafkaTopic" narrative="The Kafka topic to send the message to." stage="inKafkaTopic" /></inputs><onsuccess>5382aacb-3cc7-426e-b688-56bdc3efbcb0</onsuccess></stage><stage stageid="5382aacb-3cc7-426e-b688-56bdc3efbcb0" name="Send Message to Confluent Kafka" type="Code"><subsheetid>9bd403e8-ee47-4931-a361-58127a529ee1</subsheetid><loginhibit /><narrative></narrative><displayx>15</displayx><displayy>-30</displayy><displaywidth>120</displaywidth><displayheight>60</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><inputs><input type="text" name="BootstrapServers" expr="[gvBootstrapServers]" /><input type="text" name="KafkaTopic" expr="[inKafkaTopic]" /><input type="number" name="MessageTimeout" expr="[gvMessageTimeout]" /><input type="text" name="MessageText" expr="[inMessageText]" /></inputs><outputs><output type="flag" name="Success" stage="outSuccess" /><output type="text" name="Message" stage="outMessage" /></outputs><onsuccess>a468dfe6-732e-4e8c-bf9a-6206774ccada</onsuccess><code><![CDATA[/*
* MIT License
*
* Copyright(c) 2020 ShmoopySoft (Pty) Ltd
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
* following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
Success = false;
Message = "";
try
{
//// Create a new ProducerConfig.
ProducerConfig producerConfig = new ProducerConfig
{
BootstrapServers = BootstrapServers,
MessageTimeoutMs = Convert.ToInt32(MessageTimeout),
};
//// Create a new ProducerBuilder with the ProducerConfig defined.
//// The using block ensures the ProducerBuilder is automatically closed.
using (var producer = new ProducerBuilder<Null, string>(producerConfig)
.SetKeySerializer(Serializers.Null)
.SetValueSerializer(Serializers.Utf8)
.Build())
{
//// Send the message and await the response.
//// Note the use of GetAwaiter().GetResult(); this avoids the AggregateException wrapping
//// that happens if you use Wait() or Result.
var result =
producer.ProduceAsync(KafkaTopic,
new Message<Null, string> { Value = MessageText }).GetAwaiter().GetResult();
//// Display a confirmation.
Message = "The message was successfully sent to Kafka :-)";
Success = true;
}
}
catch (ProduceException<string, string> pe)
{
//// Return an error.
Message = pe.ToString();
}
catch (Exception ex)
{
//// Return an error.
Message = ex.ToString();
}]]></code></stage><stage stageid="515685e9-7ab9-4891-b624-f55927c9693b" name="outSuccess" type="Data"><subsheetid>9bd403e8-ee47-4931-a361-58127a529ee1</subsheetid><loginhibit /><narrative>True if sending the message was successful.</narrative><displayx>-180</displayx><displayy>120</displayy><displaywidth>150</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>flag</datatype><initialvalue /><private /><alwaysinit /></stage><stage stageid="ef3d583c-9fa8-4753-8afc-909cb9adbd6e" name="outMessage" type="Data"><subsheetid>9bd403e8-ee47-4931-a361-58127a529ee1</subsheetid><loginhibit /><narrative>The message returned by the Code Stage.</narrative><displayx>-330</displayx><displayy>120</displayy><displaywidth>150</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>text</datatype><initialvalue /><private /><alwaysinit /></stage><stage stageid="209acf58-15ee-46c0-b75a-9a6c6a18b2c8" name="Output Data Items" type="Block"><subsheetid>9bd403e8-ee47-4931-a361-58127a529ee1</subsheetid><loginhibit /><narrative></narrative><displayx>-420</displayx><displayy>75</displayy><displaywidth>330</displaywidth><displayheight>75</displayheight><font family="Arial" size="12" style="Regular" color="339966" /></stage><stage stageid="3d00d6e0-9cd1-483b-b3a7-78224abaa227" name="inMessageText" type="Data"><subsheetid>9bd403e8-ee47-4931-a361-58127a529ee1</subsheetid><loginhibit /><narrative>The message to send.</narrative><displayx>-330</displayx><displayy>15</displayy><displaywidth>150</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>text</datatype><initialvalue /><private /><alwaysinit /></stage><stage stageid="3fee4147-da3a-4ce5-8f1f-d914f2ad8030" name="Input Data Items" type="Block"><subsheetid>9bd403e8-ee47-4931-a361-58127a529ee1</subsheetid><loginhibit /><narrative></narrative><displayx>-420</displayx><displayy>-30</displayy><displaywidth>330</displaywidth><displayheight>75</displayheight><font family="Arial" size="12" style="Regular" color="99CCFF" /></stage><stage stageid="ff2dffd6-ef58-4b48-8fd3-ff877d56eb7b" name="inKafkaTopic" type="Data"><subsheetid>9bd403e8-ee47-4931-a361-58127a529ee1</subsheetid><loginhibit /><narrative>The Kafka topic name to send the message to.</narrative><displayx>-180</displayx><displayy>15</displayy><displaywidth>150</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>text</datatype><initialvalue /><private /><alwaysinit /></stage><stage stageid="a468dfe6-732e-4e8c-bf9a-6206774ccada" name="End" type="End"><subsheetid>9bd403e8-ee47-4931-a361-58127a529ee1</subsheetid><loginhibit /><narrative></narrative><displayx>15</displayx><displayy>90</displayy><displaywidth>60</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><outputs><output type="flag" name="Success" narrative="True if the message was sent." stage="outSuccess" /><output type="text" name="Message" narrative="The message returned by the Code Stage." stage="outMessage" /></outputs></stage><stage stageid="80a50050-22c9-49f7-b126-4d94982cb6e7" name="gvBootstrapServers" type="Data"><loginhibit /><narrative></narrative><displayx>-225</displayx><displayy>45</displayy><displaywidth>300</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>text</datatype><initialvalue xml:space="preserve">127.0.0.1:9092</initialvalue><alwaysinit /></stage><stage stageid="2e85cd8e-97b3-4d3c-b070-78323c224960" name="Public (Global) Data Items" type="Block"><loginhibit /><narrative></narrative><displayx>-390</displayx><displayy>0</displayy><displaywidth>330</displaywidth><displayheight>120</displayheight><font family="Arial" size="12" style="Regular" color="99CCFF" /></stage><stage stageid="cca88a07-056c-4d35-a25e-f38eebd2a89a" name="gvMessageTimeout" type="Data"><loginhibit /><narrative></narrative><displayx>-225</displayx><displayy>90</displayy><displaywidth>300</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>number</datatype><initialvalue>30000</initialvalue><alwaysinit /></stage></process></object>
<process-group id="2acacb71-9022-4cc2-851b-6705b620a174" name="Default" isDefaultGroup="True" xmlns="http://www.blueprism.co.uk/product/process-group">
<members>
<process id="b6e9b7ab-4ced-4a50-99a2-94d4e7664183" />
</members>
</process-group>
<object-group id="6b9abdd4-748c-45fc-8c1f-81f89e2b7009" name="Default" isDefaultGroup="True" xmlns="http://www.blueprism.co.uk/product/object-group">
<members>
<object id="88a61f0c-a520-417f-92e6-ce4dbf5065fa" />
</members>
</object-group>
</bpr:contents>
</bpr:release>