I'm working on a websocket application where I'm trying to have one websocket that feeds information in, and then outputs to subscribers to the endpoint. I've figure that out, but I'm wondering if there is a way to see what subscribers are subscribed and to what path?
Here is a code sample of what I'm working on.
@Autowired
private SimpMessagingTemplate template;
@MessageMapping("/{companyId}/{departmentId}")
@SendTo("/{companyId}/{departmentId}")
public void companyInformation(@DestinationVariable String companyId, @DestinationVariable String departmentId, CompanyMessage companyMessage){
String destination = "/" + companyId + "/" + departmentId;
template.convertAndSend(
destination, processCompanyMessage(companyMessage, departmentId));
}
The idea is that the information poster sends companyMessage object to the @MessageMapping endpoint, the companyId and departmentId are retrieved from this mapping.
This message is then processed based on what the departmentId is and is posted to every department that has an active subscriber to the @SendTo path.
e.g.
There are 3 websocket subscribers,
/smallCompany/booking,/smallCompany/sales,/smallCompany/inventory.
@MessageMappinggets a message from/smallCompany/sales. The method processes the message based on thedepartmentIdand posts to EVERY subscriber with the same/{companyId}, even if the/{departmentId}differs.
Any ideas if this is possible, and if not, any ideas to push me in the right direction would be great.