Skip to content

Instantly share code, notes, and snippets.

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

Zoltan Altfatter altfatterz

👨‍💻
Playing
View GitHub Profile
View clone spring-boot-heroku
$ git clone https://github.com/altfatterz/spring-boot-heroku.git
View deploy to heroku
$ heroku create // automatically adds a git remote named “heroku”
$ git push heroku master
$ heroku logs // check if the application starts up successfully
View Procfile
web: java $JAVA_OPTS -jar target/*.jar
View heroku login
$ heroku login
$ heroku keys:add ~/.ssh/id_rsa.pub
View app config
server.port: ${port:8080}
View start
$ 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
View heroku finished
$ heroku ps:scale web=0 //scale the web dynos down to zero which effectively takes all your app http-processes offline
$ heroku logout
View atmosphere message
public class Message {
private Event event;
private String sessionId;
private long time;
}
View EventService.java
@Singleton
@ManagedService(path = "/event")
public class EventService {
}
View Publish.java
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);
}
}