SQSTransport - Custom Topic Naming

I am developing an endpoint using the SQS Transport, and I found the documentation for custom topic mappings, but my topic is still being created as EndpointName-EventTypeFullName.

Here is a snippet of the relevant endpoint configuration:

var credentials = new BasicAWSCredentials(“myKey”, “mySecret”);
var sqsClient = new AmazonSQSClient(credentials, RegionEndpoint.USEast1);
var snsClient = new AmazonSimpleNotificationServiceClient(credentials, RegionEndpoint.USEast1);
var sqsTransport = new SqsTransport(sqsClient, snsClient);


If I am doing something wrong above, I am having a hard time spotting it.

Edit: I think I am going crazy, but today, the custom topic name is sort of working. I am getting a topic named “myCustomTopicName”, but I am also getting one named “EndpointName-EventTypeFullName”. I would only expect the former to be created.

I am also aware of the queue/topic name prefix and generator properties on the SqsTransport, but I would prefer to use MapEvent as I believe it is more clear. I also cannot find documentation on what the arguments to the QueueNameGenerator and TopicNameGenerator functions. If someone could provide some clarity on that, it would be very helpful. I’ve partially figured it out by running in the debugger and inspecting the values, but the second value to the TopicNameGenerator is always null with the events I have, so I can’t tell what that is for.

Welcome to the Particular discussion group, @cbristol.

When using the AmazonSQS transport, the subscriber is responsible for creating topics in SNS.

To achieve what you want, using the TopicNameGenerator on both sides, publisher and subscriber, should suffice. They must use the same topic name generation logic. There should be no need to use the MapEvent configuration API.

Thanks Mauro. Can you provide more information on the two arguments to the topic/queue name generator functions? I know the first argument to the topic name generator is the event type, but I’m not clear on the other three.

The TopicNameGenerator accepts only two parameters. The first one is the event type for which the topic needs to be created/accessed, and the second one is the prefix that is optional and thus can be null.

The generator is expected to return a string representing the topic name (must be compliant with SNS naming rules).

Thanks for sharing that document, Mauro. Somehow I got so focused on the “Custom topics mappings” I was skipping right over the part I was looking for. I am now back on the road! :slight_smile:

1 Like