While playing around with some new frameworks I’ve tried to connect my Spring Boot application to a MongoDB Atlas replicaset.
In order to do so the MongoDB Reactive Streams Java Driver needs to connect using SSL. This didn’t seem to work out of the box as I’ve got the following exception:

1
2
3
4
5
6
7
8
9
10
11
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'reactiveStreamsMongoClient'
defined in class path resource
[org/springframework/boot/autoconfigure/mongo/MongoReactiveAutoConfiguration.class]:
Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [com.mongodb.reactivestreams.client.MongoClient]:
Factory method 'reactiveStreamsMongoClient' threw exception;
nested exception is java.lang.UnsupportedOperationException:
No SSL support in java.nio.channels.AsynchronousSocketChannel.
For SSL support use com.mongodb.connection.netty.NettyStreamFactoryFactory

According to the documentation the “streamType=netty” option needs to be added to the connection URL. This however dit not make the error go away.
I’ve managed to fix the problem by setting the streamFactoryFactory to Netty using a MongoClientSettingsBuilderCustomizer.

Using Kotlin:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
@SpringBootApplication
class Application {
val eventLoopGroup = NioEventLoopGroup()
@Bean
fun mongoSettingsNettyConnectionFactoy() = MongoClientSettingsBuilderCustomizer {
it.sslSettings(SslSettings.builder()
.enabled(true)
.invalidHostNameAllowed(true)
.build())
.streamFactoryFactory(NettyStreamFactoryFactory.builder()
.eventLoopGroup(eventLoopGroup).build())
}
@PreDestroy
fun shutDownEventLoopGroup() {
eventLoopGroup.shutdownGracefully()
}
}
fun main(args: Array<String>) {
runApplication<Application>(*args)
}

Using Java:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@SpringBootApplication
public class Application {
private NioEventLoopGroup eventLoopGroup = new NioEventLoopGroup();
public static void main(String[] args) {
SpringApplication.run(SpringReactiveExampleApplication.class, args);
}
@Bean
public MongoClientSettingsBuilderCustomizer sslCustomizer() {
return clientSettingsBuilder -> clientSettingsBuilder
.sslSettings(SslSettings.builder()
.enabled(true)
.invalidHostNameAllowed(true)
.build())
.streamFactoryFactory(NettyStreamFactoryFactory.builder()
.eventLoopGroup(eventLoopGroup).build());
}
@PreDestroy
public void shutDownEventLoopGroup() {
eventLoopGroup.shutdownGracefully();
}
}

I’ve been reading up on how to use CSS Grid layout. Which reminded me of how a lot of games in the past used a grid based playing field (e.g. Bomberman,Boulder Dash,…).
So I’ve decided to get some practice an recreate a basic Snake game using JavaScript and Css Grid layout.

The code is written in vanilla JavaScript and CSS. No external libraries or Pre-processors where used.

The source is, as always, available on GitHub.

I’ve started working on a front-end project using Angular in combination with the Angular-CLI. By default Angular-CLI scaffolds a project configured to use TypeScript and the (optional) scss-sass css preprocessor.

In order to get a better grip on both technologies I’ve followed a scss and TypeScript cours on Udemy. For reference all examples and snippets have been added to my GitHub account.

Feel free to have a look:

A few weeks ago I gave a technical talk about the new reactive programming capabilities of the upcoming Spring Boot 2.0 release.

The talk discusses the need for reactive programming and the current landscape of implementations. You can view the slides here.

I’ve created a sample application to accompany the talk. It contains a web application build on Spring Boot 2.0, the MongoDB Reactive Streams Java Driver and Oboe.js.

The source is available on GitHub.

Error code 10003

We encountered an unexpected error while trying to update a capped collection in MongoDB after upgrading from 3.0 to 3.2:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Mongo> db.logItems
.update({_id : ObjectId('566839ad1d8bd6870a1ce5c2')},
{'$set' : {'processed' : true}})
WriteResult({
"nMatched" : 0,
"nUpserted" : 0,
"nModified" : 0,
"writeError" : {
"code" : 10003,
"errmsg" : "Cannot change the size of a document
in a capped collection: 28320 != 28331"
}
})

As it turns out this behaviour is to be expected. The documentation clearly states that the size of a document in a capped collection can not be changed.

Read more »