0

I am building a job scheduling application - requirement is let user and admin monitor job running on web pages. User should only see his own jobs while admin is monitoring all jobs. My design is like this, when a job is triggered it is inserted into a table with structure below. As job goes on, its status is being updated accordingly in the same table.

CREATE TABLE JOB_STATUS {
    ID INT,
    USER_ID INT,
    JOB_NAME VARCHAR,
    STATUS INT
}

I had some basic knowledge of stomp endpoints so was thinking adopting this technique. While admin users could easily monitor the whole table, I have no idea how to build a stomp endpoint for a specific user to monitor its own job status. Any help is appreciated.

LOUDKING
  • 301
  • 1
  • 13
  • Hello. Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the [How to Ask](https://stackoverflow.com/help/how-to-ask) page for help clarifying this question. – Mickael Aug 16 '18 at 13:05

1 Answers1

0

You can find exemples in this thread : Spring websocket send to specific people

In short, there is methods to send websockets to specific users :

@Controller
public class GreetingController {

    @Autowired
    private SimpMessagingTemplate messagingTemplate;

    @MessageMapping("/hello")
    public void greeting(Principal principal, HelloMessage message) throws  Exception {
        Greeting greeting = new Greeting();
        greeting.setContent("Hello!");
        messagingTemplate.convertAndSendToUser(message.getToUser(), "/queue/reply", greeting);
    }
}

So you can use it to send messages to each user listening to the running job.

Oreste Viron
  • 3,592
  • 3
  • 22
  • 34
  • Thanks for your comment. But in your example how to notify admin users? They should be monitoring whole table. – LOUDKING Aug 17 '18 at 00:26
  • You have two choices : create a topic that can be accessed by admins. Or send a message to each admin individually. – Oreste Viron Aug 17 '18 at 07:46