Skip to content

Instantly share code, notes, and snippets.

View altfatterz's full-sized avatar
👨‍💻
Playing

Zoltan Altfatter altfatterz

👨‍💻
Playing
View GitHub Profile
$ git clone https://github.com/altfatterz/spring-boot-heroku.git
$ heroku create // automatically adds a git remote named “heroku”
$ git push heroku master
$ heroku logs // check if the application starts up successfully
web: java $JAVA_OPTS -jar target/*.jar
$ heroku login
$ heroku keys:add ~/.ssh/id_rsa.pub
server.port: ${port:8080}
$ mvn clean install
$ java -jar target/*.jar // will start on 8080, with --port=<PORT> you can customize
$ curl http://localhost:8080/greeting?name=Zoltan
$ Hello Zoltan
$ heroku ps:scale web=0 //scale the web dynos down to zero which effectively takes all your app http-processes offline
$ heroku logout
public class Message {
private Event event;
private String sessionId;
private long time;
}
@Singleton
@ManagedService(path = "/event")
public class EventService {
}
BroadcasterFactory broadcasterFactory = BroadcasterFactory.getDefault();
Broadcaster eventBroadcaster = broadcasterFactory.lookup("/event");
Collection<AtmosphereResource> atmosphereResources = eventBroadcaster.getAtmosphereResources();
for (AtmosphereResource atmosphereResource : atmosphereResources) {
if (message.getSessionId().equals(getSessionId(atmosphereResource))) {
eventBroadcaster.broadcast(message, atmosphereResource);
}
}