Did Gollum die happy when he had the Ring in his hand but at the same time was being consumed by lava?
Are there any traces on this topic in book or in the movie?
It's not especially clear in the book since we don't actually see his death. He's obviously delighted to have the ring back, but he doesn't seem happy about falling, nor the fact that he's landed in painful lava.
But Gollum, dancing like a mad thing, held aloft the ring, a finger still thrust within its circle. It shone now as if verily it was wrought of living fire. 'Precious, precious, precious!' Gollum cried. 'My Precious! O my Precious!' And with that, even as his eyes were lifted up to gloat on his prize, he stepped too far, toppled, wavered for a moment on the brink, and then with a shriek he fell. Out of the depths came his last wail —Precious—, and he was gone. There was a roar and a great confusion of noise. Fires leaped up and licked the roof.
LOTR: The Return of the King: Chapter 3 - Mount Doom
In the film it's much more unambiguous. Producer Barry Osborne, in the commentary track gives us an overview of the mental states that they asked Andy Serkis to portray;
There's a lot of drama that has to play out. He finally achieves this thing that he's been chasing all this time. And right at the moment that he acquires it, and is about to master it again, he realises it's betrayed him. To his death. And all that has to play out in his face while he's falling down this chasm towards this lava.
And even when he hits this lava, it's another one of these dramatic licenses that you have to take because if you were anywhere near real lava you would burn and it would obviously be very painful but we needed to allow Gollum the moment of realisation and the moment of the lava sort of engulfing him. And to have the pain be more of of his realisation of the betrayal more than the physical pain of the lava.
I believe that Gollum died as Gollum lived: miserable and tormented. He was with the thing that he loathed more than anything in Arda. Unfortunately, Gollum would not have lived to see the Ring destroyed, though I am sure he likely died with a sense of momentary bliss in his toxic heart: the Precious was finally in his hand.
SMEAGOL on the other hand is another story entirely. Smeagol hated the Ring as much as (possible more than) Gollum did. This foul thing caused the murder of his friend and kin, and forced Smeagol (through Gollum) to taste the blood of children and to become reviled by all. Smeagol was likely not only happy that the Ring was to be destroyed, but that Gollum was to be destroyed as well. Also, he was likely to be relieved that he was to finally have peace in death. Five hundred years of forced loneliness, hatred, and sorrow makes one yearn for the embrace of sleep.
I not only think that Smeagol died happy, but that he died content. Knowing in that moment that this thing that had caused so much pain and suffering, not for just this poor creature but for all creatures, was about to be destroyed must have lifted a burden that only few in the history of Arda could have possibly known.
I hope this makes some semblance of sense.
I would say Gollum died very happy as he had the ring in his hands. Though he was about to fall into the hot lava and die he didn't even act as though he was scared and when he fell into the lava, he also did not act as though it was burning him, he just still looked very happy.
Which brings me to wondering if he felt the burning of the hot lava or not.... And why he seemed happy knowing he was going to die.